Skip to content

Assignment 2#2

Open
abeerkhe wants to merge 3 commits into
mainfrom
assignment-2
Open

Assignment 2#2
abeerkhe wants to merge 3 commits into
mainfrom
assignment-2

Conversation

@abeerkhe
Copy link
Copy Markdown
Owner

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

Answer Question 3 of Assignment 2, review my partner's code (Anna), analyze her code, and provide a reflection of that exercise and Assignment 1.

What did you learn from the changes you have made?

I learned to implement sets to compare expected values in two unordered lists (where output order and duplication is not required), and how to review and analyze somebody else's code.

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

I had a few approaches in mind that iterated over the input list in multiple ways (i.e., reordering the list and checking by list index, creating a 'range' from # of duplicate values to check within list for the existence of expected values [instead of iterating the whole list every time], etc.). Instead I opted to use sets as the data structure given the unique requirements of the problem which made it the most effective point of comparison by using the difference (-) operator, reducing time complexity of the problem.

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

N/A - biggest challenge was finding the right operation to compare sets.

How were these changes tested?

Running the code and assessing the actual output against expected.

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

I accidentally created a pull request to the Main branch in the original UofT repository, instead of to the Main branch for my fork.

Checklist

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

Copy link
Copy Markdown

@mandana-g mandana-g left a comment

Choose a reason for hiding this comment

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

Thanks Abeer, for Part 1 please consider the following:

  • Fix the range to be [0, n-1] or [0, n] depending on interpretation. For example, if the list length is n, and range is [0, n-1], then comparison_set = set(range(len(nums))).
  • Return -1 as integer, not a list containing -1.
  • Remove unused imports like numpy.
  • Use consistent function signature.

Also, consider the following for part 3:

  • Review the time complexity, keeping in mind that the if statements are not nested loops and therefore do not compound the time complexity multiplicatively.

@abeerkhe
Copy link
Copy Markdown
Owner Author

Thanks Abeer, for Part 1 please consider the following:

* Fix the range to be [0, n-1] or [0, n] depending on interpretation. For example, if the list length is n, and range is [0, n-1], then comparison_set = set(range(len(nums))).

* Return -1 as integer, not a list containing -1.

* Remove unused imports like numpy.

* Use consistent function signature.

Also, consider the following for part 3:

* Review the time complexity, keeping in mind that the if statements are not nested loops and therefore do not compound the time complexity multiplicatively.

Thanks for the feedback - the updated assignment has been submitted.

Copy link
Copy Markdown

@mandana-g mandana-g left a comment

Choose a reason for hiding this comment

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

Thanks Abeer, your assignment 2 is approved.
Just a few notes for your reference:
In Part 3, The “nested if statements” do not add O(n) each, and dictionary membership checks are O(1), not O(n). There is only a single loop over the input of length n, and all operations inside it are constant time. So, the correct time complexity is O(n).

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