if the split index was less than kthen we would make call to quick_select like thispartition step the partition step is exactly like we had in the quick sort algorithm there are couple of things worthy of notedef partition(unsorted_arrayfirst_indexlast_index)if first_index =last_indexreturn first_index pivot unsorted_array[first_indexpivot_index first_index index_of_last_element last_index less_than_pivot_index index_of_last_element greater_than_pivot_index first_index while truewhile unsorted_array[greater_than_pivot_indexpivot and greater_than_pivot_index last_indexgreater_than_pivot_index + while unsorted_array[less_than_pivot_indexpivot and less_than_pivot_index >first_indexless_than_pivot_index - if greater_than_pivot_index less_than_pivot_indextemp unsorted_array[greater_than_pivot_indexunsorted_array[greater_than_pivot_indexunsorted_array[less_than_pivot_indexunsorted_array[less_than_pivot_indextemp elsebreak