Saturday, October 27, 2007

Insertion Sort Interview Question Part 4


37. The output of 7th iteration for the sequence 5 7 0 3 4 2 6 1 using insertion sort is
a. 0 2 3 4 5 7 6 1
b.0 2 3 4 5 6 7 1

c. 0 3 5 7 4 2 6 1

d. 0 3 4 5 7 2 6 1
Ans:b

38. The output of 8th iteration for the sequence 5 7 0 3 4 2 6 1 using insertion sort is
a. 0 2 3 4 5 7 6 1
b.0 2 3 4 5 6 7 1

c. 0 1 2 3 4 5 6 7

d. 0 3 4 5 7 2 6 1
Ans:c

39. The number of positions the inserted element has moved after the 1st iteration is
a.0 b.2 c.4 d.6
Ans:a

40. The number of positions the inserted element has moved after the 2nd iteration is
a.0 b.2 c.4 d.6
Ans:a

41. The number of positions the inserted element has moved after the 3rd iteration is
a.0 b.2 c.4 d.6
Ans:b

42. The number of positions the inserted element has moved after the 4th iteration is
a.0 b.2 c.4 d.6
Ans:b

43. The number of positions the inserted element has moved after the 5th iteration is
a.0 b.2 c.4 d.6
Ans:b

44. The number of positions the inserted element has moved after the 6th iteration is
a.0 b.2 c.4 d.6
Ans:c

45. The number of positions the inserted element has moved after the 7th iteration is
a.0 b.1 c.4 d.6
Ans:b

46. The number of positions the inserted element has moved after the 8th iteration is
a.0 b.2 c.4 d.6
Ans:d


5 7 0 3 4 2 6 1 (0)
5 7 0 3 4 2 6 1 (0)
0 5 7 3 4 2 6 1 (2)
0 3 5 7 4 2 6 1 (2)
0 3 4 5 7 2 6 1 (2)
0 2 3 4 5 7 6 1 (4)
0 2 3 4 5 6 7 1 (1)
0 1 2 3 4 5 6 7 (6)

On the left side the sorted part of the sequence is shown in red. For each iteration, the number of positions the inserted element has moved is shown in brackets. Altogether this amounts to 17 steps.

47. What is the output of insertion sort after the 7th iteration given the following sequence of numbers: 7 3 5 1 9 8 4 6
a. 3 7 5 1 9 8 4 6
b. 1 3 4 5 6 7 8 9
c. 3 4 1 5 6 8 7 9
d. 1 3 4 5 6 7 9 8
Ans:b

48. What is the output of insertion sort after the 9th iteration given the following sequence of numbers: 3 10 4 6 8 9 7 2 1 5
A.1 2 3 4 6 7 8 9 10 5
b. 2 3 4 6 7 8 9 10 1 5
c. 1 2 3 4 5 6 7 8 9 10
d. 3 4 6 8 9 10 7 2 1 5
Ans:c

49. ________ is a sorting technique that sorts a set of records by inserting records into an existing sorted file.
a. quick sort
b. insertion sort
c. selection sort
d. merge sort
Ans. b

0 comments:

Advertisement

 

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