quick sort question

Reply

Join Date: Oct 2005
Posts: 38
Reputation: btech is an unknown quantity at this point 
Solved Threads: 0
btech btech is offline Offline
Light Poster

quick sort question

 
0
  #1
Feb 21st, 2006
Below is my assignment. If I understand this correctly pivot as a median is the middle of the highest, middle, and lowest numbers. In this case 35 (14, 35, 72). Please correct me if I am wrong. I do not understand how to do part b. Could someone please explain this as well? Thank you in advance.

assume the following list of keys

18, 40, 16, 82, 64, 67, 57, 50, 37, 47, 72, 14, 17, 27, 35

This list is to be sorted using the quick sort algorithm. Use pivot as the median of the first, last and middle elements of the list.

a. what is pivot?
b. give the resulting list after one call to the partition procedure.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,625
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 715
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: quick sort question

 
0
  #2
Feb 21st, 2006
>a. what is pivot?
A pivot is the one item that will be in sorted position after you partition the list.

>b. give the resulting list after one call to the partition procedure.
This depends on the partitioning algorithm.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC