performing quick-sort on general sequences in code fragment we give an implementation of the quick-sort algorithm that works on any sequence type that operates as queue this particular version relies on the linkedqueue class from section we provide more streamlined implementation of quick-sort using an array-based sequence in section our implementation chooses the first item of the queue as the pivot (since it is easily accessible)and then it divides sequence into queues leand of elements that are respectively less thanequal toand greater than the pivot we then recur on the and listsand transfer elements from the sorted lists leand back to all of the queue operations run in ( worst-case time when implemented with linked list def quick sort( ) """sort the elements of queue using the quick-sort algorithm "" len( if return list is already sorted divide firstusing first as arbitrary pivot linkedqueue linkedqueue linkedqueuedivide into leand while not is empty) if firstp enqueue( dequeue) elif first) enqueue( dequeue) elses first(must equal pivot enqueue( dequeue) conquer (with recursionsort elements less than quick sort(lsort elements greater than quick sort( concatenate results while not is empty) enqueue( dequeue) while not is empty) enqueue( dequeue) while not is empty) enqueue( dequeue)code fragment quick-sort for sequence implemented as queue