Loop to compute the frequency
for ( int i = 0 ; i < n ; i ++ ) if ( frequency . ContainsKey ( a [ i ] ) ) { frequency [ a [ i ] ] = frequency [ a [ i ] ] + 1 ; } else { frequency . Add ( a [ i ] , 1 ) ; }