Sorting Algorithms – step by step videos

Leave a comment

May 18, 2016 by oneOokay

>>>Charmander<<<

  • Quick Sort – step by step
    • Recursive
    • Pivot divides array into two parts (pivot usually is not the middle element)
    • Pivot, left and right
    • Swap pivot with left/right element until left == right
    • nLogn
    • no extra storage space
    • 先整体有序,再局部有序

  • Heap Sort – step by step
    • MinHeap: ascending order
    • MaxHeap: descending order

  • Bubble Sort

  • Insertion Sort
    • If we have n elements, then it requires (n-1) pass to sort
    • In each pass we have k comparisons, where k is the pass number
    • N2

  • Selection Sort
    • Find the smallest element in each pass and place it in the appropriate position
    • Requires n-1 pass to sort an array of n elements
    • In each pass, we have (n-k) comparisons: k is the pass number
    • 1st pass requires (n-1) comparisons; kth pass requires (n-k) comparisons; the last pass requires 1 comparison
    • N2

 

 

 

WHOLE PLAYLIST:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: