Frequency counter pattern

when to implement frequency counter patterns

Angelo Poole
Nov 2, 2020

A frequency counter is a problem solving algorithm that you can implement when you have a value that you want to find the frequency of,

it can be employed to find how many times a letter reoccurs in a string or to find out how many times a value, word, etc is repeated in any dataset given to you.

The pattern that this algorithm follows is to loop through the data given to you and start to build out an object.

Frequency counter example

In the question that appears above we are asked to find out how many times each letter appears in the string given to us. what the function does is check each letter in splitString and constructs a new object of each letter and the number of times the letter appears.

The value that is returned.

This can be helpful for questions that ask you to count the number of times things appear in datasets or the number of times key words appear and can be used to create simple data sets out of complex and hard to read datasets.

With the new object, we can also search and manipulate the data to serve whatever purpose we need it to!

--

--

Angelo Poole

Software engineer, Graduate of Flatiron school. Currently volunteering! Looking to talk to fellow engineers, please send me a message!