Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Janice Lichtman - Restricted Array assignment #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

J-C-L
Copy link

@J-C-L J-C-L commented Aug 16, 2017

Restricted Array

Congratulations! You're submitting your assignment.

Comprehension Questions

What is the time and space complexity for each method you implemented? Provide justification.

Question Answer
What is the time complexity of the length method? Provide justification. Time complexity of the length method is linear, O(n), because each element in the array is visited once.
What is the space complexity of the length method? Provide justification. Space complexity of the length method is constant, O(1), because only a single variable counter is used, and therefore the additional storage needed does not depend on the length of the array.
What is the time complexity of the print_array method? Provide justification. Time complexity of the print_array method is linear, O(n), because each element in the array is visited once.
What is the space complexity of the print_array method? Provide justification. Space complexity of the print_array method is constant, O(1), because only a single variable counter is used, and therefore the additional storage needed does not depend on the length of the array.
What is the time complexity of the reverse method? Provide justification. Time complexity of the reverse method is linear, O(n), because each element in the array is visited at most once.
What is the space complexity of the reverse method? Provide justification. Space complexity of the reverse method is constant, O(1), because the additional storage needed does not depend on the length of the array.
What is the time complexity of the search method? Provide justification. Time complexity of the search method is linear, O(n), because each element in the array is visited at most once.
What is the space complexity of the search method? Provide justification. Space complexity of the search method is constant, O(1), because the additional storage needed does not depend on the length of the array.
What is the time complexity of the delete method? Provide justification. Time complexity of the delete method is linear, O(n), because each element in the array is visited once.
What is the space complexity of the delete method? Provide justification. Space complexity of the delete method is constant, O(1), because the additional storage needed does not depend on the length of the array.
What is the time complexity of the empty method? Provide justification. Time complexity of the empty method is linear, O(n), because each element in the array is visited once.
What is the space complexity of the empty method? Provide justification. Space complexity of the empty method is constant, O(1), because the additional storage needed does not depend on the length of the array.
What is the time complexity of the find_largest method? Provide justification. Time complexity of the find_largest method is linear, O(n), because each element in the array is visited once.
What is the space complexity of the find_largest method? Provide justification. Space complexity of the find_largest method is constant, O(1), because the additional storage needed does not depend on the length of the array.
What is the time complexity of the insert_ascending method? Provide justification. Time complexity of the insert_ascending method is linear, O(n), because each element in the array is visited once.
What is the space complexity of the insert_ascending method? Provide justification. Space complexity of the insert_ascending method is constant, O(1), because the additional storage needed does not depend on the length of the array.

@shrutivanw
Copy link
Collaborator

👍 Nice work! :-)

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