Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add an item to the end of a queue.
DSA Typescript
queue.[1](item);Attempts:
3 left
💡 Hint
Common Mistakes
Using 'push' which is for stacks or arrays.
Using 'pop' which removes items.
✗ Incorrect
In a queue, adding an item is called enqueue.
2fill in blank
mediumComplete the code to remove the last item from a stack.
DSA Typescript
stack.[1]();Attempts:
3 left
💡 Hint
Common Mistakes
Using 'dequeue' which is for queues.
Using 'shift' which removes from the front.
✗ Incorrect
In a stack, removing the last added item is done with pop.
3fill in blank
hardFix the error in the code to remove the first item from a queue.
DSA Typescript
queue.[1]();Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pop' which removes from the end.
Using 'push' which adds items.
✗ Incorrect
To remove the first item from a queue, use dequeue.
4fill in blank
hardFill both blanks to create a stack and add an item.
DSA Typescript
const stack = new [1](); stack.[2](item);
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Queue' instead of 'Stack'.
Using 'enqueue' to add to a stack.
✗ Incorrect
We create a Stack and add items using push.
5fill in blank
hardFill all three blanks to create a queue, add an item, and remove an item.
DSA Typescript
const queue = new [1](); queue.[2](item); const removed = queue.[3]();
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Stack' instead of 'Queue'.
Using 'push' or 'pop' with queues.
✗ Incorrect
Create a Queue, add with enqueue, and remove with dequeue.
