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

Bo's Linked-List #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Bo's Linked-List #21

wants to merge 2 commits into from

Conversation

botrethewey
Copy link

Linked Lists

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 insert method? Provide justification. constant time, only checks the head
What is the space complexity of the insert method? Provide justification. constant space, only add 1 new node each time the method is called
What is the time complexity of the search method? Provide justification. O(n) linear time, may need to check the entire linked list till match is found
What is the space complexity of the search method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the find_max method? Provide justification. O(n) linear time, may need to check the entire linked list till max value is found
What is the space complexity of the find_max method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the find_min method? Provide justification. O(n) linear time, may need to check the entire linked list till min value is found
What is the space complexity of the find_min method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the length method? Provide justification. O(n) linear time, always need to check the entire linked list
What is the space complexity of the length method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the find_nth_from_beginning method? Provide justification. O(n) linear time, may need to check the entire linked list depending on n
What is the space complexity of the find_nth_from_beginning method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the insert_ascending method? Provide justification. O(n) linear time, may need to check the entire linked list if the node being insserted has the max value in the list
What is the space complexity of the insert_ascending method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the visit method? Provide justification. O(n) linear time, always need to check the entire linked list
What is the space complexity of the visit method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the delete method? Provide justification. O(n) linear time, may need to check the entire linked list till match is found
What is the space complexity of the delete method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the reverse method? Provide justification. O(n) linear time, always need to check entire linked list
What is the space complexity of the reverse method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the find_middle_value method? Provide justification. O(n/2) = O(n) linear time, always need to check entire linked list in increments of 2 indexes
What is the space complexity of the find_middle_value method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the find_nth_from_end method? Provide justification. O(n) linear time, always need to check the entire linked list
What is the space complexity of the find_nth_from_end method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list
What is the time complexity of the has_cycle method? Provide justification. O(n) linear time, always need to check the entire linked list regardless of it having cycle or not. Not sure about the number of iteration it would take for the two tracking variable to point to the same reference.
What is the space complexity of the has_cycle method? Provide justification. constant space, the number of variable in the method remains the same regardless of the length of the linked list

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