QuickSort Tail Call Optimization ( Reducing worst case space to Log n ) | Python3 program for the above approach ; pi is partitioning index , arr [ p ] is now at right place ; Separately sort elements before partition and after partition
def quickSort ( arr , low , high ) : NEW_LINE INDENT if ( low < high ) : NEW_LINE INDENT pi = partition ( arr , low , high ) NEW_LINE quickSort ( arr , low , pi - 1 ) NEW_LINE quickSort ( arr , pi + 1 , high ) NEW_LINE DEDENT DEDENT