Home > Enterprise >  Difference between number of comparisons and the growth of the number of the comparisons of an algor
Difference between number of comparisons and the growth of the number of the comparisons of an algor

Time:12-06

What is the difference between number of comparisons and the growth of the number of the comparisons of an algorithm ? For example for a binary search and a ternary search.

I understand that the number of comparisons is a fixed number for a specific case, but the growth takes into consideration the worst case scenario (when the element is in the 2/3 of the list in the ternary search). But I don't know if I'm right or not or if I missed something important

CodePudding user response:

The number of comparisons is the total number of comparisons made by an algorithm during its execution. In contrast, the growth of the number of comparisons is the rate at which the number of comparisons increases with respect to the size of the input.

For example, a binary search algorithm has a number of comparisons of O(log n) where n is the input size. This means that the number of comparisons increases at a rate of log n with respect to the input size. In contrast, a ternary search algorithm has a number of comparisons of O(log3 n). This means that the number of comparisons increases at a rate of log3 n with respect to the input size.

  • Related