-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathexponential.py
More file actions
32 lines (28 loc) · 744 Bytes
/
exponential.py
File metadata and controls
32 lines (28 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Exponential - O(2^n)
def exponential_2n(n):
if (n == 1):
return
exponential_2n(n - 1)
exponential_2n(n - 1)
# If we pass in 4, we are going to double our calls every single time
# Exponential - O(3^n)
def exponential_3n(n):
if (n == 1):
return
exponential_2n(n - 1)
exponential_2n(n - 1)
exponential_2n(n - 1)
# If we pass in 4, we are going to triple our calls every single time
# Exponential - O(2^n)
# function exponential_2n(n) {
# if (n === 1) return;
# exponential_2n(n - 1);
# exponential_2n(n - 1);
# }
# Exponential - O(3^n)
# function exponential_3n(n) {
# if (n === 1) return;
# exponential_2n(n - 1);
# exponential_2n(n - 1);
# exponential_2n(n - 1);
# }