From 206822562722ecec82fa7a0ff8be3e54d8ca5dc6 Mon Sep 17 00:00:00 2001 From: ROHIT SHARMA Date: Fri, 2 Oct 2020 14:25:30 +0530 Subject: [PATCH] in place quicksort --- .DS_Store | Bin 0 -> 6148 bytes c/in-place quicksort.txt | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .DS_Store create mode 100644 c/in-place quicksort.txt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ede17014823f7666b51471853d46c0bbfc2a290d GIT binary patch literal 6148 zcmeHK-D=c86#k~W)?|xxFNF3oH-gYbHmGc&2r=Cvdr>Q<>V?WS*(`1#O~NMIMc0+w z_zt#j&`0qJd=MW%&-^I+CwNt?%z-oCnVECu=bOw-1^{zMp$*gl7^EDlHA+?pujjfX zYpTQ~WTK4_eVpMQddQZ%b%AC;Gw`o5!1wM3eA=%Wx|rR+Stm|=L7WEU!Hx$6&K^V~DP z7zD~bPSg0e?FTQT{v2#&%&xx9H5C1E;t(@_%Uq8(3G7=~$>-TL-q z@}TvwVcE7lZCI05tJ$!2ckfT9rm=O$e$+WReg9$dar)_8Ob?8XG$ES`f58PAH2E`c zn8a!FPUL_J9eO+1nWuzpQSB^go7l$@p5hqK(SeH>WOXS2gbvM9gbUH1|04Q`TJly# ze_x0;$@2h@(Z(U+ivGkBf0CT(4p4(P{=X z16RNRKOZboj*h}oqBuGz5l;ZZDisSMoBu5E7)zm}u#`wOBus`9%21}B7)*v!xuyIZ zg{4Fp4yGO-O!dsv3x$c^seMbhgE%rj7t**d@f5B~iApAXVG&46a$zhZz@ z+g{tHDXF`4X>$CowMb7$xp2Qyq6ncxUB|-USMfHf5UR7dLFgzfB~l5A{t*x~=tMJc Hr40N8P*|oP literal 0 HcmV?d00001 diff --git a/c/in-place quicksort.txt b/c/in-place quicksort.txt new file mode 100644 index 0000000..d9ef8da --- /dev/null +++ b/c/in-place quicksort.txt @@ -0,0 +1,59 @@ +// in-place quicksort... also called Lomuto Partitioning method. +// here the last element is taken as the pivot element +// also, in the output, the array is printed after every successful partition + +#include +#include +#include +#include + +void display(int n, int *a) + { + for(int i=0;i=q) + return; + else + { + int m; + m=partition(p,q,n,a); + display(n,a); + quicksort(p,m-1,n,a); + quicksort(m+1,q,n,a); + } +} +int main(void) { + int ar_size; + scanf("%d", &ar_size); + int ar[ar_size], i; + for(i = 0; i < ar_size; i++) { + scanf("%d", &ar[i]); + } + + quicksort(0,ar_size-1,ar_size, ar); + + return 0; +}