Comp 1672, sections 1 and 2 Homework 8 This homework will not be collected, but it's recommended that you do it before the exam next week. 1. Problem 3 on p. 1092 2. Here's a list of integers: 20 14 2 34 23 Give all of the intermediate re-orderings of the list if we're sorting it using an insertion sort. 3. How many comparisons and how many moves are required for an array based insertion sort of n distinct elements if a. the list is already in ascending order. b. the list is in desending order. 4. Here's a list of integers: 34 56 10 4 18 2 90 5 45 12 80 78 1 19 25 67 Draw a map of the divide and merge steps that would result if we're sorting it using a merge sort. (see figure 18-54) 5. How many comparisons are necessary for an array-based merge sort of 32 items if a. the list is already in ascending order. b. the list is in desending order. 6.Name the sorting technique innocently being used in the scenarios below. a. A grader alphabetizes a stack of papers by forming a new stack as follows. Put one paper in the new stack. Take the top paper in the original stack, and put it above or below the first in the new stack, as appropriate. Generally, take the top paper in the old stack and page through the new until reaching a name later in the alphabet. Put the paper from the old stack on top of that. Continue until the old stack is empty. b. A lecturer has 4 stacks of alphabetized papers. The lecturer groups them into 2 sets of 2. With each set the lecturer forms a new stack by putting the alphabetically earlier of the papers on top of the two old stacks face down on the table, then repeating until one of the old stacks is empty. The lecturer places the remaining portion of the remaining stack face down on the new stack. Finally the lecturer flips over the two new stacks and repeats this with the two new stacks. c. A person has a to-do list with deadlines. The person does the task with the soonest deadline, crosses it of, does the remaining task with the soonest deadline, etc., until all tasks are done.("fantasy sort" is accurate, but not the answer we're after.) 7. T/F: In every search instance, a binary search will execute faster than a linear search. T/F: You should never use a linear search instead of a binary search, because a binary search is O(log n) and a linear search is O(n). T/F: You should never use a bubble sort. For the later material on the exam, make sure you can (among other things): Give code or pseudo-code for all of the search and sort algorithms we studied. Give code or pseudo-code for all linked-list algorithms. Explain what a memory leak is and find and correct such bugs. Explain what a dangling pointer is and find and correct such bugs.