edited by
3,041 views
3 votes
3 votes
Consider the following array with 7 elements for insertion sort?

25, 15, 30, 9, 99, 20, 26 In how many passes, the given sequence will be sorted? (a) 4 pass (b) 5 pass (c) 6 pass (d) More than 6 pass

Answer is 6 passes. Can anyone explain it step by step.
edited by

2 Answers

Best answer
0 votes
0 votes
Pass 0 = Array = 25, 15, 30, 9, 99, 20, 26

In pass 1, only 2 elements - 25, 15 ---> make them sorted

Pass 1 - 15, 25, 30, 9, 99, 20, 26

IN pass 2, only 3 elements - 15, 25, 30

Pass 2 - 15, 25, 30, 9, 99, 20, 26
Pass 3 - 9, 15, 25, 30, 99, 20, 26
Pass 4 - 9, 15, 25, 30, 99, 20, 26
Pass 5 - 9, 15, 20, 25, 30, 99, 26
Pass 6 - 9, 15, 20, 25, 26, 30, 99
selected by

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
2
Manoj Kumar Pandey asked Jun 20, 2018
312 views
We've been given an unordered list having n distinct elements,the no. Of comparison to find an element that is neither the 2nd minimum nor the 2nd maximum is?
0 votes
0 votes
1 answer
3
Shankar Jha asked Jun 15, 2018
599 views
Assume that merge sort algorithm in the worst case takes 30 seconds for an input of size 64 which of The following most closely approximates the maximum input size of a p...