Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b492d5f

Browse files
committedOct 14, 2024·
isssue resolved
1 parent 8e56553 commit b492d5f

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed
 

‎divide_and_conquer/quicksort.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
from typing import List
2-
3-
41
# 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:
63
"""
74
Perform quick sort on the given array in-place.
85
96
Parameters:
10-
arr (List[int]): The list of integers to sort.
7+
arr (list[int]): The list of integers to sort.
118
low (int): The starting index of the portion of the array to sort.
129
high (int): The ending index of the portion of the array to sort.
1310
@@ -34,13 +31,12 @@ def quick_sort(arr: List[int], low: int, high: int) -> None:
3431
quick_sort(arr, low, pi - 1)
3532
quick_sort(arr, pi + 1, high)
3633

37-
38-
def partition(arr: List[int], low: int, high: int) -> int:
34+
def partition(arr: list[int], low: int, high: int) -> int:
3935
"""
4036
Partition function to place the pivot element at its correct position.
4137
4238
Parameters:
43-
arr (List[int]): The list of integers to partition.
39+
arr (list[int]): The list of integers to partition.
4440
low (int): The starting index for the partition.
4541
high (int): The ending index for the partition.
4642
@@ -58,7 +54,6 @@ def partition(arr: List[int], low: int, high: int) -> int:
5854
arr[i + 1], arr[high] = arr[high], arr[i + 1] # Swap pivot
5955
return i + 1
6056

61-
6257
# Driver code to take user-defined input and sort
6358
if __name__ == "__main__":
6459
# Ask the user for input

0 commit comments

Comments
 (0)
Please sign in to comment.