| |
Constant Algorithms, O(1) | page 4 of 11 |
This relationship was not included in the chart. Here, the size of the data set does not affect the number of steps this type of algorithm takes. For example:
int howBig (int[] list)
{
return list.length;
}
The number of data in the array could vary from 0..4000, but this does not affect the howBig algorithm. It will take one step regardless of how big the data set is.
A constant time algorithm could have more than just one step, as long as the number of steps is independent of the size (N) of the data set.
|