Question

Evaluate the following algorithms in terms of its effciency,correctness,and clarity.explain your answer in 3-5 sentances

def partition(arr, low, high):
i = (low - 1)
pivot = arr[high]
for j in range(low,high):
if arr[j] <=pivot:
i = i +1
arr[i], arr[j] = arr[j], arr[i]
arr[i+1],arr[high] = arr[high], arr[i + 1]
return (i + 1)

def quicksort(arr,low,high):
if len(arr) == 1:
return arr
if low< high:
pi = partition(arr, low, high)
quicksort(arr, low, pi - 1)
quicksort(arr, pi + 1, high)

Answers

There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions