Sunday, February 5, 2012

C++ Sorting Examples

Posted by Jason On September - 29 - 2009

An Example/Tutorial of Sorting Methods in C++

In this example I show how to sort an array of numbers using a couple techniques.
Quicksort: A recursive sort done with a pivot point from the list and partitioning the list into left and right sub lists and arranging those sub lists to make every element in order.  Average Case O(n log n), with worst case O(n^2)
Bubblesort: Repeatedly stepping through the list to be sorted and comparing two items at a time and swapping them if they are in the wrong order.  Repeat until no swaps are needed. Best Case O(n), with worst case O(n^2)

C++ Sorting Examples

Add A Comment

You must be logged in to post a comment.