Skip to content

Commit a509885

Browse files
committed
chore: adjusting formatting to match standard within file
1 parent 3856c8c commit a509885

File tree

1 file changed

+14
-4
lines changed
  • allhands/spring2025/weekeleven/teamthree

1 file changed

+14
-4
lines changed

allhands/spring2025/weekeleven/teamthree/index.qmd

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ concrete data which can ultimately used to help inform implementation decisions.
3838

3939
### Generate Fibonacci using a Recursive approach
4040

41-
The recursive approach computes Fibonacci numbers by repeatedly calling the function itself. However, this method is highly inefficient because it recalculates the same values multiple times. For example, to compute fibonacci_recursive(5), the function computes fibonacci_recursive(2) three times:
41+
The recursive approach computes Fibonacci numbers by repeatedly calling the function itself.
42+
However, this method is highly inefficient because it recalculates the same values multiple
43+
times. For example, to compute fibonacci_recursive(5), the function computes
44+
fibonacci_recursive(2) three times:
45+
4246
```python
4347
fibonacci_recursive(5)
4448
├── fibonacci_recursive(4)
@@ -56,7 +60,10 @@ fibonacci_recursive(5)
5660
│ ├── fibonacci_recursive(0) → 0
5761
├── fibonacci_recursive(1) → 1
5862
```
59-
As shown above, even for a small input like n = 5, the function makes redundant calculations, leading to an exponential growth in execution time.
63+
64+
As shown above, even for a small input like n = 5, the function makes redundant calculations,
65+
leading to an exponential growth in execution time.
66+
6067
```python
6168
def fibonacci_recursive(n: int) -> int:
6269
"""Generates the Fibonacci sequence up to the nth term using recursion without memoization."""
@@ -74,8 +81,11 @@ def fibonacci_recursive(n: int) -> int:
7481
# do the recursive calculation for the nth number
7582
return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2)
7683
```
77-
It takes in integer as an input and outputs an integer which is the fibonacci number's answer. There are two base cases for this approach which the input integer, in this case "n", is equal to 0 and 1. Each function call branches into two recursive calls, forming a binary tree of depth n. This results in an exponential number of operations, making the approach extremely slow for large values of n. Therefore, the worst-time complexity is O(n^2)!
78-
84+
It takes in integer as an input and outputs an integer which is the fibonacci number's answer.
85+
There are two base cases for this approach which the input integer, in this case "n", is equal
86+
to 0 and 1. Each function call branches into two recursive calls, forming a binary tree of
87+
depth n. This results in an exponential number of operations, making the approach extremely
88+
slow for large values of n. Therefore, the worst-time complexity is $O(n^2)$!
7989

8090
### Generate Fibonacci using a Memoized approach
8191

0 commit comments

Comments
 (0)