Professional Documents
Culture Documents
Deva DS Quiz
Deva DS Quiz
For the Quick sort algorithm, what is the time complexity of the
best/worst case?
2
a. best case: O(n log(N) ) worst case: O(n )
e. None
a. O(nlog2n)
b. None
c. O(N)
2
d. O(n )
e. O(log2n)
a. sequence of values
b. pivot element
d. size of array
a. linear search
b. binary search
c. merge sort
d. Quick sort
a. O(Nlog(N))
b. O(1)
c. O(N)
d. O(log(N))
e. None
b. Exhibits the worst case performance when the initial array is sorted in reverse order.
d. Can be compared to the way a card player arranges his card from a card deck.
a. Dynamic programming
b. Greedy method
d. Backtracking
a = a + i + j;
}
a. O(n*logn)
b. O(N)
c. O(n*sqrt(N))
d. O(n*n)
Which of the following is not a stable sorting algorithm in its typical implementation.
a. quick sort
b. merge sort
c. Insertion Sort
d. Bucket sort
3
a. n
n
b. n
c. n
2
d. n
Consider the following sorting algorithms. I. Quicksort II. Heapsort III. Mergesort Which of them
perform in least time in the worst case?
b. III only
c. I and II only
d. I II and III
Consider an array of elements arr[5]= {5,4,3,2,1} , what are the steps of insertions done while doing
insertion sort in the array.
a.
45321
34521
23451
12345
b. 5 4 3 1 2
54123
51234
12345
c. 4 3 2 1 5
32154
21543
15432
d. 4 5 3 2 1
23451
34521
12345
int a = 0, i = N;
while (i > 0) {
a += i;
i /= 2;
a. O(log n)
b. O(n*logn)
c. O(N^2)
c. None of these
The worst case running times of Insertion sort, Merge sort and Quick sort, respectively, are:
2 2
a. Θ(n ), Θ(n ) and Θ(n Log n)
2
b. Θ(n ), Θ(n log n) and Θ(n log n)
2
c. Θ(n log n), Θ(n log n) and Θ(n )
2 2
d. Θ(n ), Θ(n log n) and Θ(n )