in Algorithms edited by
3,004 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.
in Algorithms edited by
3.0k views

1 comment

yes option C) 6 passes needed
0
0

2 Answers

0 votes
0 votes
Best answer
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
0 votes
0 votes

No of passes will be 6... 

Related questions

0 votes
0 votes
1 answer
1