Complexity… runs the algorithm for several sizes n, counts its steps and draws them beside n, n log n and n². The growth that fits best is named.

Algorithm Pairs

Student
  1. Click Complexity… under the diagram, then Measure: the steps grow like n².
  2. In the editor change the algorithm to one loop (add i − 1 in every step) and measure again: now like n.
Teacher
  1. n is the value of an Assign such as n = 8, or the first value the algorithm reads; the other values read are random numbers, the same each time.
  2. Compare with a template in the same chart, for example Selection Sort beside Bubble Sort.
  3. A quiz question can require a fast answer: see the question Efficiency: the sum from 1 to n, faster in the quiz Quiz: question options.