Store frequencies of elements in a hash table .
var hash = new Map ( ) ; var temp = head ; while ( temp != null ) { if ( hash . has ( temp . data ) ) hash . set ( temp . data , hash . get ( temp . data ) + 1 ) ; else hash . set ( temp . data , 1 ) ; temp = temp . next ; } temp = head ;