Storing the level of each node
level [ node ] = h ; NEW_LINE if ( parent != - 1 ) : NEW_LINE INDENT minWeight [ node ] [ 0 ] = ( min ( weight [ node ] , weight [ parent ] ) ) ; NEW_LINE maxWeight [ node ] [ 0 ] = ( max ( weight [ node ] , weight [ parent ] ) ) ; NEW_LINE DEDENT for i in range ( 1 , log ) : NEW_LINE INDENT if ( lca [ node ] [ i - 1 ] != - 1 ) : NEW_LINE DEDENT