Saturday 10 May 2014

Sorting Algorithm Folk Dances


Are you one of those souls who are always confused by different Sorting Algorithms and the subtle differences among them?  Then breathe easy. Here is the most amusing way to learn few of them. When I saw these videos on youtube, I was totally mesmerized by it and I could not resist sharing it here. 
Hats off to the choreographers and the dancers for their such rhythmic and logical steps portaying the loop and the swapping moves of sorting algorithms. You may find visual simulations/animations of these sort algorithms but nothing like these folk dances.
My favourite among them is the MergSort and Quick Sort Dance. Sharing the video  links below. Enjoy and learn..

Quick Sort

Quicksort first divides a large list into two smaller sub-lists: the low elements and the high elements. Quicksort can then recursively sort the sub-lists.

The Algorithm:
  • Pick an element, called a pivot, from the list.
  • Reorder the list so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.
  • Recursively apply the above steps to the sub-list of elements with smaller values and separately to the sub-list of elements with greater values.
The Dance


Merge Sort

Conceptually, a merge sort works as follows:
  • Divide the unsorted list into n sublists, each containing 1 element (a list of 1 element is considered sorted).
  • Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list.
The Dance


Bubble Sort 

Bubble Sort is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort.

The Dance


Insertion Sort

Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, and inserts it there. It repeats until no input elements remain. This is similar to strategy used to sometime sort the Playing card.

The Dance


Some other Sort Dances
Select-Sort with Gypsy Folk Dance

Shell-Sort with Hungarian Folk Dance




Thanks..

No comments:

Post a Comment