C++ Example – Quick Sort Algorithm

Basic Idea

  • Pick one element in the array, which will be the pivot.
  • Make one pass through the array, called a partition step, re-arranging the entries so that:
    • entries smaller than the pivot are to the left of the pivot.
    • entries larger than the pivot are to the right
  • Recursively apply quicksort to the part of the array that is to the left of the pivot, and to the part on its right.
  • No merge step, at the end all the elements are in the proper order

In this lesson we will learn how to write a source code in C++ programming language for doing simple quick sort using array in ascending order.
Online computer science courses to jumpstart your future.
Quick Sort Example :


Partner Sites