Question: Write and execute the program(Pseudocode) described in problem 4.1, page 206. Submit source code, test cases, results, and the answers to part (a) and (b).
Write and execute the program(Pseudocode) described in problem 4.1, page 206. Submit source code, test cases, results, and the answers to part (a) and (b). One of the easiest sorting algorithms to understand is one that we call Maxsort. It works as follows: Find the largest key, say max, in the unsorted section of the array (initially the whole array) and then interchange max with the element in the last position in the unsorted section. Now max is considered part of the sorted section consisting of larger keys at the end of the array; it is no longer in the unsorted section. Repeat this procedure until the whole array is sorted. a. Write an algorithm for Maxsort assuming an array E contains n elements to be sorted, with indexes 0, 1, ..., n-1. b. How many comparisons of keys does Maxsort do in the worst case? On the average?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
