I've been told that
O(2^N) denotes an algorithm whose growth will double with each additional element in the input data set
Can someone provide an example that behaves like this?
Recursive computation of Fibonacci numbers is a good example of O(2N) algorithm (though O(2N) is not a tight bound for it):
public int fib(int n) {
if (n <= 1) return n;
else return fib(n - 2) + fib(n - 1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With