Data Structures Flashcards

1
Q

How would you examine items below the top of a stack?

A

Use stack.pop() then stack.peek()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How would you examine items after the front of a queue?

A

queue.peek();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would you cycle through items in a queue without permanently removing them?

A
let thing = queue.dequeue();
queue.enqueue(thing);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly