Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Completes Data_Structures_Answers
  • Loading branch information
mattwright42 committed Mar 1, 2019
commit d7ac76baa7e89486007a2a34d0366647e0012269
17 changes: 8 additions & 9 deletions Data_Structures_Answers.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
Add your answers to the questions below.

1. What is the runtime complexity of your `depth_first_for_each` method?
1. What is the runtime complexity of your `depth_first_for_each` method? N/A

2. What is the space complexity of your `depth_first_for_each` function?
2. What is the space complexity of your `depth_first_for_each` function? N/A

3. What is the runtime complexity of your `breadth_first_for_each` method?
3. What is the runtime complexity of your `breadth_first_for_each` method? This will be O(n) as it is visiting each node once.

4. What is the space complexity of your `breadth_first_for_each` method?
4. What is the space complexity of your `breadth_first_for_each` method? This will be O(n) because the size of the queue scales with the size of the tree.

5) What is the runtime complexity of the provided code in `names.py`? O(n \*\* 2) from the nested loop.

5. What is the runtime complexity of the provided code in `names.py`?
6) What is the space complexity of the provided code in `names.py`? I think this is O(n) because the size of the duplicates array increases with the size of the 'names' files.

6. What is the space complexity of the provided code in `names.py`?
7) What is the runtime complexity of your optimized code in `names.py`? I think O(n) - it is running the function once?

7. What is the runtime complexity of your optimized code in `names.py`?

8. What is the space complexity of your optimized code in `names.py`?
8) What is the space complexity of your optimized code in `names.py`? O(n)
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylint = "*"
autopep8 = "*"

[packages]

Expand Down
120 changes: 118 additions & 2 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.