?
Solved

Writing a Quick sort in C++

Posted on 2003-02-20
4
Medium Priority
?
1,084 Views
Last Modified: 2010-05-18
For my AP class i need to write a quick sort with iterative?? which i don't know what it means.... i can write bubble and insertion sorts but this sort confuses me i don't know where to start.. any ideas would be very helpful.. thanx
Birdman
0
Comment
Question by:corey2024
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 12

Expert Comment

by:Salte
ID: 7987895
Quicksort is by its very nature a recursive sort. It is not iterative. If you want a non-recursive you therefore have to make your own stack

Alf
0
 
LVL 1

Accepted Solution

by:
Intern earned 200 total points
ID: 7987905
example code:
http://ciips.ee.uwa.edu.au/~morris/Year2/PLDS210/qsort1a.html


Quick Sort: The quick sort algorithm contains two phases: the partition phase, which splits an array of data into two separates partitions, and the sort phase, which sorts each partition. The quick sort algorithm is extremely popular, and is also known as the "divide and conquer" method.

A quick sort algorithm divides an array of items into partitions and calls a quick sort procedure to recursively sort the partitions. Each call to the quick sort procedure divides the results into two further groups until each item in the array is ordered correctly.
0
 

Expert Comment

by:Rapture273
ID: 7988163
If you are allowed, you may prefer to use a linked-list class to make your list in the first place. This automatically sorts the data.
If you are not allowed to do that, then try the algorithm offered by Intern above.
0
 
LVL 2

Expert Comment

by:udil
ID: 8868888
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I appreciate any comments that would help me to make a recommendation.

In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Udil
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question