Skip to content

Complete assignment 1 - #1

Open
tutoringjedi wants to merge 1 commit into
mainfrom
assignment-1
Open

Complete assignment 1#1
tutoringjedi wants to merge 1 commit into
mainfrom
assignment-1

Conversation

@tutoringjedi

Copy link
Copy Markdown
Owner

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

Populated assignment_1.ipynb with a solution to the First Duplicate in List problem, including a paraphrase, two custom examples, a coded solution, complexity analysis, and an alternative approach description

What did you learn from the changes you have made?

How a set enables O(1) average-time membership lookup, making it the ideal abstract data type for duplicate detection problems
The importance of scanning left to right and returning immediately on the first repeated value — this correctly handles the "first duplicate" constraint without any sorting or counting
The trade-off between time and space complexity: the set-based solution is O(n) time / O(n) space, while the brute-force nested loop is O(n²) time / O(1) space

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

A brute-force nested loop: for each element, scan all elements to its left and check for a match — correct but O(n²) time
A dictionary-based counter: use a dict to count occurrences and return the first key whose count reaches 2 — functionally equivalent to the set approach but uses slightly more memory since it stores counts, not just presence

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

The completed notebook wasn't being picked up by git add because the file on disk was identical to the repo version — resolved by ensuring the downloaded completed notebook was copied into the correct folder before staging
origin was pointing to UofT-DSI/algorithms_and_data_structures instead of the fork — resolved with git remote set-url origin
The repo had no main branch since it was forked with assignment-1 as default — resolved by creating and pushing a main branch locally

How were these changes tested?

All five test cases (three provided examples plus two custom ones) were run with assert statements to verify correctness
Edge cases covered: no duplicates (returns -1), multiple duplicates (returns the one whose second occurrence comes first)

A reference to a related issue in your repository (if applicable)

Checklist

  • I can confirm that my changes are working as intended

@efantinatti efantinatti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment 1 Review - Neil Chakraborty (@tutoringjedi)

Feedback

What went well:

  • Excellent paraphrase of the first‑duplicate problem.
  • Two comprehensive examples with assertions.
  • Efficient set‑based solution with inline tests.
  • Detailed explanation of why the solution works and its complexity.
  • Clearly described a nested‑loop alternative and compared complexities.
Criterion Passed? Comments
If there are no missing cells or similar cells to the oficial repo Passed Submission contains unique answers
Problem accurately stated Passed
Two correct examples Passed
Correct and efficient code Passed
Clear explanation and complexity Passed
Clear alternative solution Passed

Score: 6/6

Best
@efantinatti

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.

2 participants