Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.(A) 1(B) 2(C) 3(D) 4

Answer»
2.

Which one of the following is an application of Queue Data Structure?(A) When a resource is shared among multiple consumers.(B) When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes(C) Load Balancing(D) All of the above

Answer»
3.

Following is C like pseudo code of a function that takes a Queue as an argument, and uses a stack S to do processing.void fun(Queue *Q){Stack S; // Say it creates an empty stack S// Run while Q is not emptywhile (!isEmpty(Q)){// deQueue an item from Q and push the dequeued item to Spush(&S, deQueue(Q));}// Run while Stack S is not emptywhile (!isEmpty(&S)){// Pop an item from S and enqueue the poppped item to QenQueue(Q, pop(&S));}}What does the above function do in general?(A) Removes the last from Q(B) Keeps the Q same as it was before the call(C) Makes Q empty(D) Reverses the Q

Answer»
4.

Consider the following operation along with Enqueue and Dequeue operations onqueues, where k is a global parameter.MultiDequeue(Q){ m = k while (Q is not empty and m > 0) { Dequeue(Q) m = m - 1 }}What is the worst case time complexity of a sequence of n MultiDequeue() operations on an initially empty queue? (GATE CS 2013)(A) (B) (C) (D) (A) A(B) B(C) C(D) D

Answer»
5.

Consider the following pseudo code. Assume that IntQueue is an integer queue. What does the function fun do?void fun(int n){IntQueue q = new IntQueue();q.enqueue(0);q.enqueue(1);for (int i = 0; i < n; i++){int a = q.dequeue();int b = q.dequeue();q.enqueue(b);q.enqueue(a + b);print(a);}}(A) Prints numbers from 0 to n-1(B) Prints numbers from n-1 to 0(C) Prints first n Fibonacci numbers(D) Prints first n Fibonacci numbers in reverse order.

Answer»