Complete assignment 2 - #2
Open
tutoringjedi wants to merge 1 commit into
Open
Conversation
tianyi21
suggested changes
Jun 30, 2026
tianyi21
left a comment
There was a problem hiding this comment.
Hi Neil,
Thank you for submitting your ADS A2. It looks like you submitted A2 for the production module. Please double check and re-submit the correct file.
Thanks,
Tianyi [LS]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
Added the completed assignment_2.ipynb, which includes: a solution to the assigned Part 1 coding problem (Path to Leaves using DFS with backtracking), a code review of my partner's Assignment 1 submission (Valid Bracket Sequence), and a written reflection on both assignments.
What did you learn from the changes you have made?
I learned that DFS with backtracking is better suited than BFS for collecting root-to-leaf paths, because the call stack naturally tracks the current path without needing to store copies alongside every queue element. Through the code review process, I also learned to read code critically for edge cases — I identified a bug in my partner's solution that causes an IndexError when a closing bracket is encountered on an empty stack (e.g. input ")(").
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
For the Path to Leaves problem, I initially considered BFS. While BFS works, it requires storing a copy of the current path with every node in the queue, making it less memory-efficient than the DFS + backtracking approach, which reuses a single list.
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
The main challenge was ensuring the path list was correctly snapshotted at each leaf node. Since the same list is mutated throughout the recursion, calling results.append(path) would store a reference that changes as backtracking continues — so I used results.append(list(path)) to capture a copy at each leaf.
How were these changes tested?
The bt_path function was tested against all examples provided in the assignment, plus two additional cases: a single-node tree (where the root is also the only leaf) and a right-skewed tree. All outputs matched expected results.
A reference to a related issue in your repository (if applicable)
Checklist