Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

-Use this array of integer for the problems 1A, 1B, and 1C: 7 5 2 91 1 4 3 6 - E

ID: 3701788 • Letter: #

Question

-Use this array of integer for the problems 1A, 1B, and 1C: 7 5 2 91 1 4 3 6 - Each of these problems is worth 3 points. A. B. C. Show the contents of the array each time a selection sort changes it while sorting the array into ascending order. Show the contents of the array each time an insertion sort changes it while sorting the array into ascending order. Show the contents of the array each time a Shell sort changes it while sorting the array into ascending order. D. 2 pointsSuppose you want to find the largest entry in an unsorted array of n entries. Algorithm A searches the entire array sequentially and records the largest entry seen so far. Algorithm The array 1s initially B sorts the array into descending order and then reports the first entry as the largest. Compare the time efficiency of the two approaches. 1 2 3 4 5 E. 10 points Consider an n by n array of integer values. Write an algorithm to sort the rows of the array by their first value. Implement your algorithm. The code for this problem is provided in the Assignment-03-Code.zip archive. The array after sorting is 1 2 3 4 Your output must be identical to the output to the right. 5 2 3 4 PART 2 -Queues, Deques, and Priority Queues, 19 points A. 3 pointsAfter the following statements execute, what are the contents of the queue? Queuelnterface myQueue new LinkedQueue myQueue.enqueue Jane"; myQueue.enqueueJess") myQueue.enqueueJill"); myQueue.enqueue(myQueue.dequeue); myQueue.enqueue(myQueue.getFront()): myQueue.enqueueJim"); String name myQueue.dequeue() myQueue.enqueue(myQueue.getFront())

Explanation / Answer

C) Shell sort array changes are as follows :

Gap = 9 -> 7 5 2 9 1 1 4 3 6
Gap = 4 -> 1 1 2 3 6 5 4 9 7
Gap = 2 -> 1 1 2 3 4 5 6 9 7

D) The time complexity of the first approach is O(n) where n is the number of elements in the array as we are performing a linear search on the array. If you are not familiar with Big O notation then understand it as we are basically performing around n steps to reach our answer.

The time complexity of second approach is O(nlogn) because there is no sorting algorithm which can sort given numbers in better than nlogn steps.

So it means first approach is taking less number of steps and is thus better.