Professional Documents
Culture Documents
UID: 20BCG1092
Aim : Design a quick sort with random pivoting using Lomuto partition scheme.
Program Code
#include <cstdlib>
#include <time.h>
#include <iostream>
// as pivot, places
// pivot
int pivot = arr[high];
// smaller element
i++;
swap(arr[i], arr[j]);
return (i + 1);
// low .. high
srand(time(NULL));
swap(arr[random], arr[high]);
return partition(arr, low, high);
QuickSort
arr[p] is now
at right place */
quickSort(arr, pi + 1, high);
}
}
int i;
cout<<arr[i]<<" ";
// Driver Code
int main()
int arr[] = { 3, 4, 8, 4, 1, 8 };
quickSort(arr, 0, n - 1);
printArray(arr, n);
return 0;
}
Output
6. LEARNING OUTCOMES: