DSA - Basic Ques

  1. Diff methods of arrays we can use while solving stack and queue problems?
  2. Difference between stack and queue
  3. TIP:- Valid parenthesis (must solve problem for interview)

queue methods are enqueue and dequeue is empty front

stack is last in first out and queue is first in last out

1 Like

1, For stack: push() and pop() methods of arrays can be used.
For queue: push() and shift() methods of arrays can be used.
2, A stack is a Last-In-First-Out (LIFO) data structure where elements are added and removed from the
top is stack
a First-In-First-Out (FIFO) data structure where elements are added at the rear and removed from
the front is queue

1 Like
  1. Stack follows LIFO while Queue follows FIFO data structure type
    LIFO= last in first out
    FIFO= First in first out
1 Like

stack
1 push
2 pop
3 peek
queue
1 enqueue
2 dequeue

Stack uses lifo and queue use fifo

1 Like