Mathematics
 
 
MTH 568 - Compuational Science

 

Home
 

Syllabus
 

Course Outline
 

Resources
 

Contact Info


 
Sorting Algorithms





 Sorting algorithms take a list of items in a desired order, usually in ascending or descending order (if the data is numeric).  There are a variety of sorting algorithms and variations on these algortihms. 
 
 

  • Selection Sort
    • The smallest element in the entire array of n elments is placed as the first element.  The smallest of the n-1 elements is then placed as the second element.  This process is then continued until there is only one element remaining.
    • selection sort demonstration
    • selection_sort.c
    • data.old

     
  • Insertion Sort
    • An algorithn that sorts by repeatedly taking the next item in an array and inserting it into the final data structure in its proper order with respect to the items already inserted.
    • insertion sort demonstration
    • insertion_sort.c
    • data.old

     
  • Merge Sort
    • A sorting algorithm in which the items are split recursively into two groups, sorted, and then merged into a final sorted sequence.
    • merge sort demonstration 1, demonstration 2
  • Quick Sort
    • One element of the array is chosen, and is called the pivot.  The pivot is then placed in its proper place upon comparing it with then entries of the array.  Entries smaller than the pivot are to the left of the pivot, while entries larger than the pivot are to its right.  The algorithm is then repeated recursively to elements to the left of the pivot and to the elements to the right of the pivot.
    • quick sort demonstration