954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

quick sort question

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.

btech
Light Poster
38 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

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

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You