Queue elements after sorted Index are already sorted . This function returns index of minimum element from front to sortedIndex
static int minIndex ( ref Queue < int > q , int sortedIndex ) { int min_index = - 1 ; int min_val = int . MaxValue ; int n = q . Count ; for ( int i = 0 ; i < n ; i ++ ) { int curr = q . Peek ( ) ;