Base case : Leaf node
if ( adj [ u ] . Count == 0 ) return ; minItr [ u ] = adj [ u ] . Count ; int [ ] minItrTemp = new int [ minItr [ u ] ] ; int k = 0 ; foreach ( int itr in adj [ u ] ) { int currentChild = ( int ) itr ; getMinIterUtil ( currentChild , minItr ) ; minItrTemp [ k ++ ] = minItr [ currentChild ] ; } Array . Sort ( minItrTemp ) ; for ( int i = 0 , j = minItrTemp . Length - 1 ; i < j ; i ++ , j -- ) { int temp = minItrTemp [ i ] ; minItrTemp [ i ] = minItrTemp [ j ] ; minItrTemp [ j ] = temp ; } for ( k = 0 ; k < adj [ u ] . Count ; k ++ ) { int temp = minItrTemp [ k ] + k + 1 ; minItr [ u ] = Math . Max ( minItr [ u ] , temp ) ; } }