View on GitHub

401-reading-notes

Class 10

Stacks And Queues

What is a Stack?

Terms:

push

the method used to put nodes or items to the stack

pop

the method used to remove nodes or items from the stack

top

it’s the top of the stack

peek

the method used to view the value of the top in the stack

is Empty

returns true when stack is empty otherwise return false

For all four methods the Big O notation is O(1)

stack concepts

FILO * first in last out *

means that the first item added in the stack will be the last item to be popped out of the stack.

LIFO last in first out

means that the last item added in the stack will be the first item to be popped out the stack.

TERMS OF QUEUE:

enqueue

dequeue

front

rear

peek

the method used to view the value of the top in the queue.

isEmpty

returns true when queue is empty otherwise return false.

For all four methods the Big O notation is O(1)

FIFO first in first out

LILO last in last out