Mergesort+(natalg+példa)

Így nézne ki az összefésülő rendezés natalg pszeudo-nyelven megadva:

code MergeSort algorithm is the following To merge sort an array is to       If size of array is at least 1: Slice array to part1 and part2. Recoursively sort part1. Recoursively sort part2. Merge part1 and part2. To slice an array into arrays part1 and part2 is to       Let end and middle pointing to the first element of array. While end is a valid pointer: If this is not the first time: Advance middle by 1. Advance end by 2. Point part1 to the subset of the array from the first element to middle. Advance middle by 1. Point part2 to the subset of the array from middle to the last element. To merge arrays part1 and part2 into an array is to       Let arr1 and arr2 enumerate elements of part1 and part2 from the begining to the end by one. While arr1 or arr2 not empty: If top of arr1 less then or equal to the top of arr2 or arr2 is empty: Pop arr1 to the end of array. If top of arr2 less then or equal to the top of arr1 or arr1 is empty: Pop arr2 to the end of array. code