Skip to content

Instantly share code, notes, and snippets.

@vaidehijoshi
Last active June 20, 2017 16:12
Show Gist options
  • Save vaidehijoshi/5252c7a687cec03834c4d7625960b337 to your computer and use it in GitHub Desktop.
Save vaidehijoshi/5252c7a687cec03834c4d7625960b337 to your computer and use it in GitHub Desktop.
var items = [19, 22, 63, 105, 2, 46];
quickSort(items, 0, items.length - 1);
> ** pivot is: 63
> ** left is: 19
> ** right is: 46
> l is now pointing to: 22
> l is now pointing to: 63
> ** now swapping l and r pointers: 63 46
> ** now swapping l and r pointers: 105 2
> ** pivot is: 105
> ** pivot is: 22
> ** left is: 19
> ** right is: 2
> l is now pointing to: 22
> ** now swapping l and r pointers: 22 2
> r is now pointing to: 2
> ** pivot is: 46
> ** pivot is: 19
> ** left is: 19
> ** right is: 2
> ** now swapping l and r pointers: 19 2
> ** pivot is: 19
> ** pivot is: 46
> ** left is: 46
> ** right is: 22
> ** now swapping l and r pointers: 46 22
> ** pivot is: 46
> ** pivot is: 105
> ** left is: 105
> ** right is: 63
> ** now swapping l and r pointers: 105 63
> ** pivot is: 105
>> (6) [2, 19, 22, 46, 63, 105]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment