Complete the following tasks to pass the tests and this assignment. Just like in the checkpoint, you will use a linked list in your implementation.
- In the src/Stack.js file:
-
Complete the
push()
method to insert a node into the stack. The method should accept an argument data that represents the data to be stored in the node. Use the provided _Node class to create new node instances. -
Complete the
pop()
method to remove a node from a stack. The method should return the data stored in the deleted node.
- In the src/Queue.js file:
-
Complete the
enqueue()
method to insert a node into a queue. The method should accept an argument data that represents the data to be stored in the node. Use the provided _Node class to create new node instances. -
Complete the
dequeue()
method to remove a node from a queue. The method should return the data stored in the deleted node. If the queue is already empty, then the method should return undefined.