weiweiz1 commited on
Commit
0960e1e
·
verified ·
1 Parent(s): e0cfa41

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +5 -5
README.md CHANGED
@@ -63,7 +63,7 @@ content: Here's a quicksort algorithm implementation in Python:
63
 
64
  ```python
65
  def quicksort(arr):
66
- """
67
  Sorts an array using the quicksort algorithm.
68
 
69
  Args:
@@ -71,12 +71,12 @@ def quicksort(arr):
71
 
72
  Returns:
73
  None (sorts in-place)
74
- """
75
  if len(arr) <= 1:
76
  return
77
 
78
  def partition(low, high):
79
- """Partition function using the last element as pivot"""
80
  pivot = arr[high]
81
  i = low - 1 # Index of smaller element
82
 
@@ -89,7 +89,7 @@ def quicksort(arr):
89
  return i + 1
90
 
91
  def quicksort_helper(low, high):
92
- """Recursive helper function"""
93
  if low < high:
94
  # Partition the array and get pivot index
95
  pi = partition(low, high)
@@ -143,7 +143,7 @@ if __name__ == "__main__":
143
  import random
144
 
145
  def quicksort_random(arr):
146
- """Quicksort with random pivot selection for better average performance"""
147
  def partition(low, high):
148
  # Randomly select pivot and swap with last element
149
  random_index = random.randint(low, high)
 
63
 
64
  ```python
65
  def quicksort(arr):
66
+ '''
67
  Sorts an array using the quicksort algorithm.
68
 
69
  Args:
 
71
 
72
  Returns:
73
  None (sorts in-place)
74
+ '''
75
  if len(arr) <= 1:
76
  return
77
 
78
  def partition(low, high):
79
+ '''Partition function using the last element as pivot'''
80
  pivot = arr[high]
81
  i = low - 1 # Index of smaller element
82
 
 
89
  return i + 1
90
 
91
  def quicksort_helper(low, high):
92
+ '''Recursive helper function'''
93
  if low < high:
94
  # Partition the array and get pivot index
95
  pi = partition(low, high)
 
143
  import random
144
 
145
  def quicksort_random(arr):
146
+ '''Quicksort with random pivot selection for better average performance'''
147
  def partition(low, high):
148
  # Randomly select pivot and swap with last element
149
  random_index = random.randint(low, high)