Question 41
Quicksort is run on two inputs shown below to sort in ascending order taking the first element as pivot,
(i) 1, 2, 3,......., n (ii) n, n-1, n-2,......, 2, 1
Let C1 and C2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then,
Question 42
∀i, j ∈ [1...n−1], A[i][j] < A[i][j+1] and A[i][j] < A[i+1][j]Fill in the blanks: a) The smallest item in the array is at A[i][j] where i=..................and j=...................... b) The smallest item is deleted. Complete the following O(n) procedure to insert item x (which is guaranteed to be smaller than any item in the last row or column) still keeping A partially sorted.
procedure insert (x: integer); var i,j: integer; begin i:=1; j:=1, A[i][j]:=x; while (x > ...... or x > ......) do if A[i+1][j] < A[i][j] ......... then begin A[i][j]:=A[i+1][j]; i:=i+1; end else begin ............ end A[i][j]:= ............. end .
Question 44
Question 45
Question 46
Consider the following sorting algorithms.
I. Quicksort
II. Heapsort
III. Mergesort
Which of them perform in least time in the worst case?
Question 47
Which one of the following in place sorting algorithms needs the minimum number of swaps?
Question 50
There are 61 questions to complete.