fix merge conflicts

This commit is contained in:
Krishna Vedala 2020-05-27 18:45:52 -04:00
parent 9249fa2743
commit 7238aa7869
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -1,16 +1,6 @@
<<<<<<< HEAD
/* C implementation QuickSort */
#include <iostream>
int partition(int arr[], int low, int high) {
int pivot = arr[high]; // pivot
int i = (low - 1); // Index of smaller element
=======
/** /**
* * @file
* copyright The Algorithms * @brief Quick sort algorithm
* Author -
* Correction - ayaankhan98
* *
* Implementation Details - * Implementation Details -
* Quick Sort is a divide and conquer algorithm. It picks and element as * Quick Sort is a divide and conquer algorithm. It picks and element as
@ -35,28 +25,23 @@ int partition(int arr[], int low, int high) {
#include <iostream> #include <iostream>
/** /**
* This function takes last element as pivot, places * This function takes last element as pivot, places
* the pivot element at its correct position in sorted * the pivot element at its correct position in sorted
* array, and places all smaller (smaller than pivot) * array, and places all smaller (smaller than pivot)
* to left of pivot and all greater elements to right * to left of pivot and all greater elements to right
* of pivot * of pivot
* *
*/ */
int partition(int arr[], int low, int high) { int partition(int arr[], int low, int high) {
int pivot = arr[high]; // taking the last element as pivot int pivot = arr[high]; // taking the last element as pivot
int i = (low - 1); // Index of smaller element int i = (low - 1); // Index of smaller element
>>>>>>> major-corrections-to-files
for (int j = low; j < high; j++) { for (int j = low; j < high; j++) {
// If current element is smaller than or // If current element is smaller than or
// equal to pivot // equal to pivot
if (arr[j] <= pivot) { if (arr[j] <= pivot) {
<<<<<<< HEAD
i++; // increment index of smaller element i++; // increment index of smaller element
=======
i++; // increment index of smaller element
>>>>>>> major-corrections-to-files
int temp = arr[i]; int temp = arr[i];
arr[i] = arr[j]; arr[i] = arr[j];
arr[j] = temp; arr[j] = temp;
@ -68,41 +53,27 @@ int partition(int arr[], int low, int high) {
return (i + 1); return (i + 1);
} }
<<<<<<< HEAD /**
* The main function that implements QuickSort
* arr[] --> Array to be sorted,
* low --> Starting index,
* high --> Ending index
*/
void quickSort(int arr[], int low, int high) { void quickSort(int arr[], int low, int high) {
if (low < high) { if (low < high) {
int p = partition(arr, low, high); int p = partition(arr, low, high);
=======
/**
* The main function that implements QuickSort
* arr[] --> Array to be sorted,
* low --> Starting index,
* high --> Ending index
*/
void quickSort(int arr[], int low, int high) {
if (low < high) {
int p = partition(arr, low, high);
>>>>>>> major-corrections-to-files
quickSort(arr, low, p - 1); quickSort(arr, low, p - 1);
quickSort(arr, p + 1, high); quickSort(arr, p + 1, high);
} }
} }
<<<<<<< HEAD
void show(int arr[], int size) {
for (int i = 0; i < size; i++) std::cout << arr[i] << "\n";
=======
// prints the array after sorting // prints the array after sorting
void show(int arr[], int size) { void show(int arr[], int size) {
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++) std::cout << arr[i] << " ";
std::cout << arr[i] << " ";
std::cout << "\n"; std::cout << "\n";
>>>>>>> major-corrections-to-files
} }
// Driver program to test above functions /** Driver program to test above functions */
int main() { int main() {
int size; int size;
std::cout << "\nEnter the number of elements : "; std::cout << "\nEnter the number of elements : ";