Time Complexity
Definition: Time Complexity
The Time complexity of an algorithm measures the time (read number of elementary steps) required to
compute an algorithm as a function of the size of the input. Time complexity of an algorithm is usually expressed using Big O Notation (see the next section).
The Future? (a recent article).
The Tower of Hanoi
The idea is to move a stack of disks from one peg to
another, one at a time but always putting a smaller disk on top of a bigger
one The measure of Time complexity is the number of individual disk moves required as a function of the size
of the stack.
- 1 disk requires 1 step.
- 2 disks require 3 steps = 2*(number of steps required for 1 disk)+1.
- n disks require 2*(number of steps required for n-1 disks)+1.
- The number of steps required for n disks is ≥ 2n-1. Which we will call the Time
Complexity of solving the Tower of Hanoi.