Data Structures Flashcards
1
Q
How would you examine items below the top of a stack?
A
Use stack.pop() then stack.peek()
2
Q
How would you find out how many items are in a stack?
A
let items = 0; while (stack.peek() !== undefiend) { stack.pop(); items++; } return items;
3
Q
How would you examine items after the front of a queue?
A
queue.peek();
4
Q
How would you cycle through items in a queue without permanently removing them?
A
let thing = queue.dequeue(); queue.enqueue(thing);