1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-01 21:32:35 +02:00

Change of content in 104-exponential.md

There's a mistake in the example that has been provided.  According to the complexity analysis, the current example yields the exponential time complexity, not the previous one.
This commit is contained in:
Yutharsan
2024-05-22 11:12:31 +05:30
committed by GitHub
parent 359e3e1900
commit 5b496e8403

View File

@@ -6,7 +6,7 @@ Exponential algorithms are those that grow at a rate of 2^n. This means that for
def exponential(n):
if n == 0:
return 1
return 2 * exponential(n - 1)
return exponential(n - 1) + exponential(n - 1)
```
As you can see, the algorithm's runtime grows exponentially. For each additional input, the algorithm will take twice as long to run.