additional optimizations for quick-sort an algorithm is in-place if it uses only small amount of memory in addition to that needed for the original input our implementation of heap-sortfrom section is an example of such an in-place sorting algorithm our implementation of quick-sort from code fragment does not qualify as in-place because we use additional containers leand when dividing sequence within each recursive call quick-sort of an array-based sequence can be adapted to be in-placeand such an optimization is used in most deployed implementations performing the quick-sort algorithm in-place requires bit of ingenuityhoweverfor we must use the input sequence itself to store the subsequences for all the recursive calls we show algorithm inplace quick sortwhich performs in-place quick-sortin code fragment our implementation assumes that the input sequencesis given as python list of elements in-place quick-sort modifies the input sequence using element swapping and does not explicitly create subsequences insteada subsequence of the input sequence is implicitly represented by range of positions specified by leftmost index and rightmost index the def inplace quick sort(sab) """sort the list from [ato [binclusive using the quick-sort algorithm "" if >breturn range is trivially sorted pivot [blast element of range is pivot left will scan rightward right - will scan leftward while left <right scan until reaching value equal or larger than pivot (or right marker while left <right and [leftpivot left + scan until reaching value equal or smaller than pivot (or left marker while left <right and pivot [right] right - if left <rightscans did not strictly cross [left] [rights[right] [leftswap values leftright left right shrink range put pivot into its final place (currently marked by left index [left] [bs[ ] [left make recursive calls inplace quick sort(saleft inplace quick sort(sleft bcode fragment in-place quick-sort for python list