51.0k views
2 votes
Give a big-O estimate for the number of comparisons used by the algorithm that determines the number of 1s in a bit string of length n by examining each bit of the string to determine whether it is a 1 bit.

User Boneill
by
8.4k points

2 Answers

4 votes
the notation would be O (n-1) because there would be no need to compare with the first bit however this notation is most commonly noted as O (n) but the first is also technically correct
User Lejhbah
by
8.5k points
4 votes
The answer is "n".
Algorithms are considered to be process or a bunch or rules that is to be followed in computing or calculating. This is used to solve operational problems especially by a computer. Algorithms perform data processing, calculation, or/and automated reasoning activities.


User John Mark
by
8.4k points