Created
March 14, 2015 23:11
-
-
Save frydaykg/96a93560e8788b59d070 to your computer and use it in GitHub Desktop.
Lamuto partition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int Partition(int *a, int l, int r) { | |
| r--; | |
| int pivot = a[r]; | |
| int i = l - 1; | |
| for (int j = l; j < r; j++) | |
| if (a[j] <= pivot) | |
| swap(a[++i], a[j]); | |
| swap(a[++i], a[r]); | |
| return i; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment