Skip to content

Assignment 2#92

Closed
alf-99 wants to merge 2 commits into
UofT-DSI:mainfrom
alf-99:assignment-2
Closed

Assignment 2#92
alf-99 wants to merge 2 commits into
UofT-DSI:mainfrom
alf-99:assignment-2

Conversation

@alf-99
Copy link
Copy Markdown

@alf-99 alf-99 commented Feb 8, 2026

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

  • [ x] I can confirm that my changes are working as intended

alf-99 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
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 8, 2026

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.

@alf-99 alf-99 closed this Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant