Moves given minimum element to rear of queue
void insertMinToRear ( queue < int > & q , int min_index ) { int min_val ; int n = q . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int curr = q . front ( ) ; q . pop ( ) ; if ( i != min_index ) q . push ( curr ) ; else min_val = curr ; } q . push ( min_val ) ; }