The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
124 views
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.
asked in Algorithms by (181 points)
edited by | 124 views

1 Answer

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
answered by (97 points)
selected by

Related questions

0 votes
1 answer
1
0 votes
1 answer
4
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,814 questions
54,518 answers
188,351 comments
75,294 users