is there anyone who can sort this using quick sort - Sajha Mobile
SAJHA MOBILE
is there anyone who can sort this using quick sort
Posts 7 · Viewed 7687 · Go to Last Post
b27b
· Snapshot 0
Like · Likedby · 0
3,1,4,1,5,9,2,6,5,3,5
Bhojpure01
· Snapshot 20
Like · Liked by · 0
Are you talking about excel or other specific program?
b27b
· Snapshot 26
Like · Liked by · 0
not in excel bud. I actually need on quick sort diagram.
dynamite
· Snapshot 74
Like · Liked by · 0
Sorry double post.
Last edited: 14-Oct-10 03:26 PM
dynamite
· Snapshot 74
Like · Liked by · 0
Grabbing the pseudocode from wikipedia: 

function
quicksort(array)
     
var list less, greater
     
if length(array) 1  
         
return array  
     
select and remove a pivot value pivot from array
     
for each x in array
         
if x pivot then append x to less
         
else append x to greater
     
return concatenate(quicksort(less), pivot, quicksort(greater))

iteration 1
Choose any pivot, for instance, 3 looks good then
(1,1,2,3)  3 (4,5,9,6,5,5)

iteration 2
Chosing 2 as pivot, and 5 as pivot
(1,1) (2) (3) 3 (4,5,5) 5 (6,9)

Third iteration, chosing random pivot as usual
(1) (1) 2 (3) 3 (4,5) 5 5 (6)(9)

Last iteration:
1 1 2 3 3 4 5 5 5 6 9

I hope I am right and I hope it helps. :)



techGuy
· Snapshot 110
Like · Liked by · 0
From http://en.wikipedia.org/wiki/Quicksort


You can replace ur numbers to following diagram
default061
· Snapshot 244
Like · Liked by · 0


This should give you the concept. Yellow bg indicates May Not Require This Step/Possibly wrong. Red int indicates the selection of the partition point ( starting at right -- pivot). underlined is the position where it is sorted.  { } =selection of block . When block has one element, it is sorted already. Bold int= upcoming pivot
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 3 · Viewed 552 · Likes 1
· Posts 4 · Viewed 920 · Likes 3
· Posts 17 · Viewed 1506 · Likes 1
· Posts 11 · Viewed 571
· Posts 3 · Viewed 193
· Posts 1 · Viewed 110
· Posts 1 · Viewed 76
· Posts 1 · Viewed 133
· Posts 3 · Viewed 396 · Likes 1
· Posts 6 · Viewed 619



Your Banner Here
Travel Partners
Travel House Nepal