Saturday, October 27, 2007

Sorting Interview Questions Part 8


21. If p < r then
q Partition (A, p, r)
Recursive call to Sort (A, p, q)
Recursive call to Sort (A, q + r, r)
Which sorting algorithm does SORT represent
a.Selection sort b.quick sort c.Bubble sort d.Merge sort
Ans:b
22. _____Sort chooses as pivot one of the items in the array to be sorted.
a.Selection sort b.quick sort c.Bubble sort d.Merge sort
Ans:b
23.Selection sort is
a.inplace
b.noninplace
c.out place
d.none
Ans:a
24.Bubble sort is
a.inplace
b.noninplace
c.out place
d.none
Ans:a
25.Which of the following are stable algorithms
a.Bubble b.Insertion c.Both d.none
Ans:c

26. An array in sorted order is in __________.
a.Max-heap
b.Min-heap
c.Random heap
d.none
Ans:a

27. Assuming all the elements to be distinct, where in the Max-heap might the smallest element reside ?

a.In the root position
b.In the left sub tree of the root
c.In the right sub tree of the root
d.In some leaf node
Ans:d

28. Assuming all the elements to be distinct, where in the Min-heap might the smallest element reside ?

a.In the root position
b.In the left sub tree of the root
c.In the right sub tree of the root
d.In some leaf node
Ans:a

29. Assuming all the elements to be distinct, where in the Max-heap might the largest element reside ?

a.In the root position
b.In the left sub tree of the root
c.In the right sub tree of the root
d.In some leaf node
Ans:a

30. Assuming all the elements to be distinct, where in the Min-heap might the largest element reside ?

a.In the root position
b.In the left sub tree of the root
c.In the right sub tree of the root
d.In some leaf node
Ans:d

31.Which of the following is useful in implementing quick sort
a.Stack
b.List
c.Queue
d.Set
Ans:a

32.Which of the following algorithm design technique is used for quick sort
a.Dynamic programming
b.Backtracking
c.Divide and conquer
d.Greedy method
Ans:c

33. If the records that it's sorting are in main memory then the sort is called as
a. internal
b. external
c. stable
d. none of this
Ans. a

34. An array of elements is sorted by choosing a pivot element & by partition.The sorting process is called
a. Partition exchange sort
b. Quick sort
c. a and b
d. selection sort
Ans. c

35. In min-heap property,each node in a tree has a key which is _______ than or equal to the key of its parent.
Ans. greater

0 comments:

Advertisement

 

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