Skip to content

Commit d423fd0

Browse files
committed
finished questions
1 parent 963eedc commit d423fd0

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Data_Structures_Answers.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
Add your answers to the questions below.
22

33
1. What is the runtime complexity of your ring buffer's `append` method?
4-
4+
O(1)
55
2. What is the space complexity of your ring buffer's `append` function?
6-
6+
O(1)
77
3. What is the runtime complexity of your ring buffer's `get` method?
8-
8+
O(n)
99
4. What is the space complexity of your ring buffer's `get` method?
10-
10+
O(n)
1111

1212
5. What is the runtime complexity of the provided code in `names.py`?
13-
13+
O(n^2) - nested for loop
1414
6. What is the space complexity of the provided code in `names.py`?
15-
15+
O(n)
1616
7. What is the runtime complexity of your optimized code in `names.py`?
17-
17+
O(n)
1818
8. What is the space complexity of your optimized code in `names.py`?
19+
O(1)

ring_buffer/ring_buffer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def __init__(self, capacity):
1212
def append(self, item):
1313
# print(self.current)
1414
# print(self.storage)
15+
1516
# replaces the item for the "current" index
1617
self.storage[self.current] = item
1718
# check that our current position is not beyond the lists length

0 commit comments

Comments
 (0)