Tino APCS

Constant Algorithms, O(1)

  1. This relationship was not included in the Order of Algorithms graph. Here, the size of the data set does not affect the number of steps this type of algorithm takes. For example:

    public int howBig(ArrayList<Integer> list){
            return list.size();
    }
    
  2. The number of data items 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.

  3. 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.

Dark Mode

Outline