top of page
  • Facebook
  • Twitter
  • Instagram

Top Data-Structures Interview Questions

Mobiprep handbooks are free downloadable placement preparation resources that can help you ace any company placement process. We have curated a list of the 40 most important MCQ questions which are asked in most companies such as Infosys, TCS, Wipro, Accenture, etc. The placement handbooks also have detailed explanations for every question ensuring you revise all the questions with detailed answers and explanations.

Question

5

Explanation

Why stack is ideal for recursion operation.
.


Because of its LIFO (Last In First Out) property, it remembers the elements & their positions, so it exactly knows which one to return when a function is called.

Question

6

Explanation

Write a program to reverse a queue using stack.


void reverse_queue()
{
while(!(front == rear))
{stack.push(dequeue());}
stack.push(dequeue());
printf("\nREVERSED QUEUE : ");
while(!stack.empty())
{
printf("%d ",stack.top());
stack.pop();
}
printf("\n");
exit(0);
}

Question

7

Explanation

What is the minimum number of queues required for priority queue implementation?


Minimum number of queues required for priority queue implementation is two. One for storing actual data and one for storing priorities.

Question

8

Explanation

What is priority queue?

A priority queue is a collection in which items can be added at any time, but the only item that can be removed is the one with the highest priority.
Applications of priority queue:
>Prim's algorithm implementation can be done using priority queues.
>Dijkstra's shortest path algorithm implementation can be done using priority queues.
>A* Search algorithm implementation can be done using priority queues.
>Priority queues are used to sort heaps.
>Priority queues are used in operating system for load balancing and interrupt handling.
>Priority queues are used in huffman codes for data compression.
>In traffic light, depending upon the traffic, the colors will be given priority.

bottom of page