Data Structures and C Programming



Data Structures Interview Questions

Pg : 1 , 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14



Stores a set of elements in a particular order
Stack principle: LAST IN FIRST OUT = LIFO
It means: the last element inserted is the first one to be removed

In computer science, a stack is a last in, first out (LIFO) abstract data type and linear data structure.
A stack can have any abstract data type as an element, but is characterized by only three fundamental operations: push, pop and stack top.

Stack Applications

Real life

Pile of books
Plate trays

Other applications related to computer science

Program execution stack
Evaluating expressions

Stacks have some useful terminology associated with them:

Push To add an element to the stack
Pop To remove an element from the stock
Peek To look at elements in the stack without removing them
LIFO Refers to the last in, first out behavior of the stack
FILO Equivalent to LIFO


Queue is a data structure that maintain "First In First Out" (FIFO) order. And can be viewed as people queuing up to buy a ticket. In programming, queue is usually used as a data structure for BFS (Breadth First Search)

Operations on queue Q are :

1. enqueue - insert item at the back of queue Q

2. dequeue - return (and virtually remove) the front item from queue Q

3. init - intialize queue Q, reset all variables