Data Structures Viva Question & Answers (Stack & Queue)

1. What is Data Structure? 

->A data structure is a model for organizing and storing data. Stacks, Queue, Linked Lists, and Trees are the examples of different data structures. Data structures are classified as either linear or non-linear:

 ▪ A data structure is said to be linear if only one element can be accessed from an element directly. Eg: Stacks, Lists, Queues.

 ▪ A data structure is non-linear if more than one elements can be accessed from an element directly. Eg: Trees, Graphs, Heap 


2. Define ADT? 

->An abstract data type is a set of objects together with a set of operations. Abstract data types are mathematical abstraction. Objects such as lists, sets, graphs, trees can be viewed as abstract data types.


 3. What do you mean by LIFO and FIFO?

->LIFO stands for 'Last In First Out', it says how the data to be stored and retrieved. It means the data or element which was stored last should come out first. Stack follows LIFO. FIFO stands for 'First In First Out', here the data(or element) which was stored first should be the one to come out first. It is implemented in Queue


4. What is Stack?

->A stack is a list of elements in which insertion and deletions can take place only at one end, this end is called as stack 'top'. Only top element can be accessed. A stack data structure has LIFO (Last In First Out) property. A stack is an example of linear data structure.


5. What operations can be done on Stack? 

->The following operations can be performed on stack: 

   ▪ Push operation inserts new element into stack.

   ▪ Pop operation deletes the top element from the stack.

   ▪ Peek returns or give the top element without deleting it. 

   ▪ IsEmpty() operation returns whether stack is empty or not.


 6. List some applications of stack?

->Some well-known applications of stack are as follow:

    1. Infix to Postfix conversion.

    2.Evaluation of postfix expression.

    3. Check for balanced parentheses in an expression.

    4. Stack is very important data structure being used to implement function calls efficiently.

   5. Parsing

   6. Simulation of recursion function

   7. String reverse using stack. 


7. What is a Queue? 

->A Queue is a particular data structure in which the elements in the collection are kept in order. Unlike Stack, queue is opened at both ends. Queue follows 'FIFO' method where element is inserted from rear end and deleted or removed from front end.


 8. What operations can be done on Queue? 

->The following operations can be performed on queue: 

   ▪ Enqueue operation inserts new element in rear of the list.

   ▪ Dequeue operation deletes the front element from the list. 

   ▪ Isempty() operation checks whether queue is empty or not.


 9. Where do we use Queue? 

->Some well-known applications of queue are as follow: 

   1. For finding level order traversal efficiently.

   2. For implementing BFS efficiently.

   3. For implementing Kruskal algorithm efficiently.

Post a Comment

Previous Post Next Post