create a empty vector to store frequencies and initialize it by 0. Size of vector is maximum value ( which is last value in sorted array ) plus 1.
let freq = new Array ( arr [ n - 1 ] + 1 ) ; for ( let i = 0 ; i < arr [ n - 1 ] + 1 ; i ++ ) { freq [ i ] = 0 ; }