ebonnecab/Core-Data-Structures

Feedback: Linked Lists, Stacks & Queues

Closed this issue · 0 comments

  • The tests for the linked list insert_at_index and replace do not pass. insert_at_index seems to handle the base case, but what happens if the node is at the head or tail? In replace, the error never seems to get raised. The error relies on prev_node to be set, but prev_node doesn't seem to get changed in replace. Even if prev_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.