mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
fix merge conflicts
This commit is contained in:
parent
9249fa2743
commit
7238aa7869
@ -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
|
||||
=======
|
||||
/**
|
||||
*
|
||||
* copyright The Algorithms
|
||||
* Author -
|
||||
* Correction - ayaankhan98
|
||||
* @file
|
||||
* @brief Quick sort algorithm
|
||||
*
|
||||
* Implementation Details -
|
||||
* Quick Sort is a divide and conquer algorithm. It picks and element as
|
||||
@ -46,17 +36,12 @@ 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 i = (low - 1); // Index of smaller element
|
||||
>>>>>>> major-corrections-to-files
|
||||
|
||||
for (int j = low; j < high; j++) {
|
||||
// If current element is smaller than or
|
||||
// equal to pivot
|
||||
if (arr[j] <= pivot) {
|
||||
<<<<<<< HEAD
|
||||
i++; // increment index of smaller element
|
||||
=======
|
||||
i++; // increment index of smaller element
|
||||
>>>>>>> major-corrections-to-files
|
||||
int temp = arr[i];
|
||||
arr[i] = arr[j];
|
||||
arr[j] = temp;
|
||||
@ -68,13 +53,6 @@ int partition(int arr[], int low, int high) {
|
||||
return (i + 1);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
void quickSort(int arr[], int low, int high) {
|
||||
if (low < high) {
|
||||
int p = partition(arr, low, high);
|
||||
|
||||
=======
|
||||
|
||||
/**
|
||||
* The main function that implements QuickSort
|
||||
* arr[] --> Array to be sorted,
|
||||
@ -84,25 +62,18 @@ void quickSort(int arr[], int low, int high) {
|
||||
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, 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
|
||||
void show(int arr[], int size) {
|
||||
for (int i = 0; i < size; i++)
|
||||
std::cout << arr[i] << " ";
|
||||
for (int i = 0; i < size; i++) std::cout << arr[i] << " ";
|
||||
std::cout << "\n";
|
||||
>>>>>>> major-corrections-to-files
|
||||
}
|
||||
|
||||
// Driver program to test above functions
|
||||
/** Driver program to test above functions */
|
||||
int main() {
|
||||
int size;
|
||||
std::cout << "\nEnter the number of elements : ";
|
||||
|
Loading…
Reference in New Issue
Block a user