Saturday, October 27, 2007

Quick Sort Interview Question Part 1


1.Quick sort is 1.in-place 2.non in-place 3.stable 4.non-stable a.1 and 3 b.1 and 4 c.2 and 3 d.2 and 4
Ans:b


2.What is the average case complexity for quick sort algorithm a.O(n) b.O(n*n) c.O(nlogn) d.O(logn)
Ans:c


3.What is the worst case complexity for quick sort algorithm a.O(n) b.O(n*n) c.O(nlogn) d.O(logn)
Ans:b

4.What is the best case complexity for quick sort algorithm a.O(n) b.O(n*n) c.O(nlogn) d.O(logn)
Ans:c

5.Quick sort is also known as a. Pointer sort b.External sorting c.Both d.none
Ans:c

6.What is the output of quick sort after the 1st iteration given the following sequence of numbers: 65 70 75 80 85 60 55 50 45 a. 60 45 50 55 65 85 80 70 75 b.60 45 50 55 65 85 80 75 70 c. 45 60 50 55 65 85 80 75 70 d. 60 45 50 65 55 85 80 75 70
Ans:b

7.Which sorting technique is also called partition exchange sort? a.selection sort b.quick sort c.bubble sort d.merge sort
Ans:b

8. In which cases are the time complexities same in quick sort? a. Worst and Best b. Best and Average c. Worst and Average d. Worst, average and Best
Ans:b

9. Quick sort uses ___________. a. Divide and Conquer Technique b. Greedy Approach c. Back Tracking d. None of the above
Ans. a

10. What pattern of splits gives the worst-case performance for quick sort? a. Ascending order. b. Descending order.
c. Any order.
d. None of the above.
Ans. b

11.In quick sort the pivot value is usually the
a.first element
b.last element
c.middle element
d.any element
Ans: d

12. What is the output of quick sort after the 2nd iteration given the following sequence of numbers: 65 70 75 80 85 60 55 50 45
a. 60 45 50 55 65 85 80 70 75
b.60 45 50 55 65 85 80 75 70
c.55 45 50 60 65 70 80 75 85
d. 60 45 50 65 55 85 80 75 70
Ans:c

13.What is the output of quick sort after the 3rd iteration given the following sequence of numbers: 65 70 75 80 85 60 55 50 45
a. 60 45 50 55 65 85 80 70 75 b.60 45 50 55 65 85 80 75 70 c.55 45 50 60 65 70 80 75 85 d. 50 45 55 60 65 70 80 75 85
Ans:d

14.What is the output of quick sort after the 4th iteration given the following sequence of numbers: 65 70 75 80 85 60 55 50 45
a. 45 50 55 60 65 70 75 80 85
b.60 45 50 55 65 85 80 75 70
c.55 45 50 60 65 70 80 75 85
d. 50 45 55 60 65 70 80 75 85
Ans:a

15. Which of the following statements about Quick sort is/are incorrect?
a. Average running time is O(N log N).
b. The best case always occurs when the pivot partitions the set of numbers to be sorted into two equal-sized subsets.
c. The worst case always occurs when the pivot partitions the set of numbers to be sorted into two equal-sized subsets.
d. The worst case always occurs when the smallest item is selected from the items to be sorted as the pivot.
Ans. c



16. Which statement(s) is/are correct for the Quick sort algorithm?
(i) Quick Sort is still best sorting algorithms, known for sequential computers
(ii) It works by partitioning the file into two sub files and sorting two sub files independently.
(iii) The pivot value can be chosen in an arbitrary way.
a.(i) only
b.(i) and (iii) only
c.(i), (ii) and (iii).
d.(ii) and (iii)
Ans:c

0 comments:

Advertisement

 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com