Assignment 2#92
Closed
alf-99 wants to merge 2 commits into
Closed
Conversation
added 2 commits
February 1, 2026 23:08
- Implement first_duplicate function with O(n) time solution - Provide two new test examples - Add time/space complexity analysis - Include alternative solution explanation
…dd tests, complete partner code review
|
Hello, thank you for your contribution. If you are a participant, please close this pull request and open it in your own forked repository instead of here. Please read the instructions on your onboarding Assignment Submission Guide more carefully. If you are not a participant, please give us up to 72 hours to review your PR. Alternatively, you can reach out to us directly to expedite the review process. |
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)
I completed the second assignment, which included solving the "Check Duplicates in Tree" problem and doing a code review of my partner's valid brackets solution from Assignment 1. I implemented the tree duplicate finder using BFS and a set, and wrote a detailed analysis of my partner's submission.
What did you learn from the changes you have made?
I learned how to approach tree problems with BFS to ensure we check nodes level by level, which is important when we need the duplicate closest to the root. For the code review part, I practiced reading and evaluating someone else's solution carefully—understanding their logic, checking correctness, and thinking about efficiency trade-offs.
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
For the tree problem, I considered using DFS with a hash map tracking both values and depths, then returning the duplicate with the minimum depth. That would also work but might be less intuitive than BFS for this "closest to root" requirement.
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
The main challenge was interpreting the tree input format—the examples were given as lists, which I realized are level-order representations. I sketched the tree diagrams manually to confirm the structure before coding. Also, during the partner review, understanding their pair-removal bracket logic took a few walkthroughs with examples.
How were these changes tested?
I tested the tree duplicate function with the given examples and additional cases, including a single node, an empty tree, and trees with duplicates at different levels. For the review, I manually traced my partner's examples and added one of my own to verify their solution's behavior.
A reference to a related issue in your repository (if applicable)
N/A – this is the first submission for Assignment 2.
Checklist