is there anyone who can sort this using quick sort

Archived from the original Sajha.com — preserved as posted, replies can no longer be added here.
Start a New Discussion
Archived Post

3,1,4,1,5,9,2,6,5,3,5

b27b · Oct 14, 2010 12:48 PM · 18,278 views

6 Replies

Are you talking about excel or other specific program?

bhojpure01 · Oct 14, 2010 1:25 PM

not in excel bud. I actually need on quick sort diagram.

b27b · Oct 14, 2010 1:31 PM

Sorry double post. Last edited: 14-Oct-10 03:26 PM

dynamite · Oct 14, 2010 3:26 PM

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. :)

dynamite · Oct 14, 2010 3:26 PM

From http://en.wikipedia.org/wiki/Q... You can replace ur numbers to following diagram

techGuy · Oct 14, 2010 3:45 PM

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

default061 · Oct 15, 2010 3:00 AM

This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.

Start a New Discussion

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all