Slideshow

Monday, 25 February 2013


Consider a list of numbers 9, 20, 6, 10, 14, 8, 60, 11 given. Sort them using Quick
Sort. Give step wise calculation. 

Ans:
9,20,6,10,14,8,60,11
choosing 9 as Pivot(Pass—1)
6,8,9,10,14,20,60,11
The sublist on the left side of 9 is sorted therefore, no more sorting on left sublist
Now choosing 10 as Pivot (pass – 2)
(10 is already in the position)
6,8,9,10,14,20,60,11
Choosing 14 as Pivot (pass –3)
6,8,9,10,11,14,60,20
Choosing 60 as Pivot [pass – 4)
6,8,9,10,11,14,20,60

No comments:

Post a Comment