Skip to content

Cynthia - Linked List#10

Open
cynthiacd wants to merge 2 commits intoAda-C7:masterfrom
cynthiacd:master
Open

Cynthia - Linked List#10
cynthiacd wants to merge 2 commits intoAda-C7:masterfrom
cynthiacd:master

Conversation

@cynthiacd
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 - always inserting at head
What is the space complexity of the insert method? Provide justification. constant cause with every new node the size of the linked list increases by the same amount
What is the time complexity of the search method? Provide justification. O(n) - transversing through once
What is the space complexity of the search method? Provide justification. constant - not changing size
What is the time complexity of the find_max method? Provide justification. O(n) - transversing through once & depends on size
What is the space complexity of the find_max method? Provide justification. constant - not adding new node - only returning value
What is the time complexity of the find_min method? Provide justification. O(n) - transversing through once - depends on list size
What is the space complexity of the find_min method? Provide justification. constant - returning value of one node
What is the time complexity of the length method? Provide justification. O(n) transversing through once and depends on list size
What is the space complexity of the length method? Provide justification. constant - returning constant value
What is the time complexity of the find_nth_from_beginning method? Provide justification. O(n) - depends on the length of list and must start at beginning and move through each node till you get to the position you want
What is the space complexity of the find_nth_from_beginning method? Provide justification. constant - returning value of a single node
What is the time complexity of the insert_ascending method? Provide justification. O(n) - must transverse through list till you find the value position you want to insert
What is the space complexity of the insert_ascending method? Provide justification. constant - only adding one new node each time you call method
What is the time complexity of the visit method? Provide justification. O(n) - depends on length of linked list
What is the space complexity of the visit method? Provide justification. constant cause just printing out data - not saving that data or making any new data types to do so ?
What is the time complexity of the delete method? Provide justification. O(n) - depends on length of linked list - must transverse through list till you find node you want to remove
What is the space complexity of the delete method? Provide justification. constant - removing one node
What is the time complexity of the reverse method? Provide justification. O(n) - depends on length of list
What is the space complexity of the reverse method? Provide justification. constant - not creating a new list just reversing the pointers
What is the time complexity of the find_middle_value method? Provide justification. O(n) - depends on length of list
What is the space complexity of the find_middle_value method? Provide justification. constant - returning single data value of middle node
What is the time complexity of the find_nth_from_end method? Provide justification. O(n) - depends on length of linked list - this is true for the most efficient approach. If you transverse through twice the complexity is n^2
What is the space complexity of the find_nth_from_end method? Provide justification. constant - returning single data value
What is the time complexity of the has_cycle method? Provide justification. O(n) - depends on length of list
What is the space complexity of the has_cycle method? Provide justification. constant - returning true or false

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