Construct a function that implements quick sort algorithm. The partition() function has been pre defined and displayed below.
Consider data is a list, first is the first element's index and last is the last element's index

def partition(data, first, last): pivot_value = data[first] left_mark = first+1 right_mark = last done = False while not done: while left_mark <= right_mark and data[left_mark] <= pivot_value: left_mark = left_mark + 1 while data[right_mark] >= pivot_value: right_mark = right_mark-1 if right_mark < left_mark: done = True else: temp = data[left_mark] data[left_mark] = data[right_mark] data[right_mark] = temp temp = data[first] data[first] = data[right_mark] data[right_mark] = temp return right_mark

Reset Check