From 3dc4f87db3d2149abf72526b56c4b65aeaae621e Mon Sep 17 00:00:00 2001 From: styles3544 <56684660+styles3544@users.noreply.github.com> Date: Thu, 17 Oct 2019 19:33:46 +0530 Subject: [PATCH] Create quick_sort.cpp --- styles/quick_sort.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 styles/quick_sort.cpp diff --git a/styles/quick_sort.cpp b/styles/quick_sort.cpp new file mode 100644 index 0000000..6d03069 --- /dev/null +++ b/styles/quick_sort.cpp @@ -0,0 +1,13 @@ +/* low --> Starting index, high --> Ending index */ +quickSort(arr[], low, high) +{ + if (low < high) + { + /* pi is partitioning index, arr[pi] is now + at right place */ + pi = partition(arr, low, high); + + quickSort(arr, low, pi - 1); // Before pi + quickSort(arr, pi + 1, high); // After pi + } +}