I am having trouble with this algorithm. I was wondering if anyone could offer assistance and also an explanation.
Describe an algorithm that, upon input of n real numbers, a1,a2,...,an, and another number, x, determines how many ai are equal to x.
I am totally lost. From reading my book, I am thinking that this is the answer.
Step 1. Set C=0
Step 2. For i=1 to n, if ai=x replace C by C+1
Step 3. Output C
Any help is appreciated.