1.Suppose the insertion sort as presented in was applied to the list Gene, Cheryl, Alice, and Brenda. Describe the organization of the list at the end of each execution of the body of the outer while structure.
2.Why would we not want to change the phrase “greater than” in the while statement in Figure 5.11 to “greater than or equal to”?
3.A variation of the insertion sort algorithm is theselection sort.It begins by selecting the smallest entry in the list and moving it to the front. It then selects the smallest entry from the remaining entries in the list and moves it to the second position in the list. By repeatedly selecting the smallest entry from the remaining portion of the list and moving that entry forward, the sorted version of the list grows from the front of the list, while the back portion of the list consisting of the remaining unsorted entries shrinks. Use our pseudocode to express a function similar to that in Figure 5.11 for sorting a list using the selection sort algorithm.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here