1
- from typing import List
2
-
3
-
4
1
# Function to implement Quick Sort
5
- def quick_sort (arr : List [int ], low : int , high : int ) -> None :
2
+ def quick_sort (arr : list [int ], low : int , high : int ) -> None :
6
3
"""
7
4
Perform quick sort on the given array in-place.
8
5
9
6
Parameters:
10
- arr (List [int]): The list of integers to sort.
7
+ arr (list [int]): The list of integers to sort.
11
8
low (int): The starting index of the portion of the array to sort.
12
9
high (int): The ending index of the portion of the array to sort.
13
10
@@ -34,13 +31,12 @@ def quick_sort(arr: List[int], low: int, high: int) -> None:
34
31
quick_sort (arr , low , pi - 1 )
35
32
quick_sort (arr , pi + 1 , high )
36
33
37
-
38
- def partition (arr : List [int ], low : int , high : int ) -> int :
34
+ def partition (arr : list [int ], low : int , high : int ) -> int :
39
35
"""
40
36
Partition function to place the pivot element at its correct position.
41
37
42
38
Parameters:
43
- arr (List [int]): The list of integers to partition.
39
+ arr (list [int]): The list of integers to partition.
44
40
low (int): The starting index for the partition.
45
41
high (int): The ending index for the partition.
46
42
@@ -58,7 +54,6 @@ def partition(arr: List[int], low: int, high: int) -> int:
58
54
arr [i + 1 ], arr [high ] = arr [high ], arr [i + 1 ] # Swap pivot
59
55
return i + 1
60
56
61
-
62
57
# Driver code to take user-defined input and sort
63
58
if __name__ == "__main__" :
64
59
# Ask the user for input
0 commit comments