text: Frequency Measuring Techniques for Competitive Programming | C # program to count frequencies of array items having small values . ; Create an array to store counts . The size of array is limit + 1 and all values are initially 0 ; Traverse through array elements and count frequencies ( assuming that elements are limited by limit ) ; Driver Code
code: using System ; class GFG { static void countFreq ( int [ ] arr , int n , int limit ) { int [ ] count = new int [ limit + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) count [ arr [ i ] ] ++ ; for ( int i = 0 ; i <= limit ; i ++ ) if ( count [ i ] > 0 ) Console . WriteLine ( i + " ▁ " + count [ i ] ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 5 , 6 , 6 , 5 , 6 , 1 , 2 , 3 , 10 , 10 } ; int n = arr . Length ; int limit = 10 ; countFreq ( arr , n , limit ) ; } }