Stacks and Queues Flashcards

1
Q

how do you initiate a stack?

A

Stack stackname = new Stack();

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

how do you add, remove, and peek from a stack?

A

stackname. push(“Value”);
stackname. pop();
stackname. peek();
stackname. search(“Value”); //to find index of an element

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

how do you initiate a queue?

A

Queue queuename = new LinkedList();

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

how do you add, remove, and peek from a queue?

A

queuename. offer(“Value”);
queuename. poll();
queuename. peek();

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