Feedback: Linked Lists, Stacks & Queues
Closed this issue · 0 comments
anselb commented
- The tests for the linked list
insert_at_index
andreplace
do not pass.insert_at_index
seems to handle the base case, but what happens if the node is at the head or tail? Inreplace
, the error never seems to get raised. The error relies onprev_node
to be set, butprev_node
doesn't seem to get changed inreplace
. Even ifprev_node
was correctly set, would it ever trigger the conditional to raise an error? - While the stacks and queues implementations work, the LinkedStack is implemented inefficiently. You want to push and pop items at the head of the linked list rather than the tail. While adding to a linked list is O(1) time complexity if at the head or tail, popping at the tail has a time complexity of O(n) for iterating through the linked list and setting the tail node to the second to last node in the linked list. O(1) is possible for popping a LinkedStack.