Back

Exponential execution performance O(2N)

Exponential execution time O(2N)
The kind of algorithm represented by O(2N) is one whose performance will double with each data element added to it. We can represent this using a graph:

bogo4

Programming examples that are O(2N)
Examples that are O(N2) include recursive Fibonacci implementation algoirthms, implementations of the Towers have Hanoi. 

Python example
Here is the code to work out what the value of the seventh element is in the Fibonacci series:

fib

You can change the 7 to any number you want, to return the value of the element in that position. This is an example of an algorithm that can be described as O(2N).

Back