From 22a8553f11c3cb527ac054fb422f8284baa48db3 Mon Sep 17 00:00:00 2001 From: UN997 Date: Thu, 4 Oct 2018 01:27:13 +0530 Subject: [PATCH] Added quick sort --- sorting/quick_sort.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 sorting/quick_sort.py diff --git a/sorting/quick_sort.py b/sorting/quick_sort.py new file mode 100644 index 0000000..0ad549c --- /dev/null +++ b/sorting/quick_sort.py @@ -0,0 +1,42 @@ + +def quickSort(alist): + + quickSortHelper(alist,0,len(alist)-1) + +def quickSortHelper(alist,first,last): + + if first= pivotvalue and rightmark >= leftmark: + rightmark = rightmark -1 + + if rightmark < leftmark: + done = True + else: + temp = alist[leftmark] + alist[leftmark] = alist[rightmark] + alist[rightmark] = temp + + temp = alist[first] + alist[first] = alist[rightmark] + alist[rightmark] = temp + + return rightmark + +alist = [54,26,93,17,77,31,44,55,20] +quickSort(alist) +print(alist) \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy