Priority Queue and De-Queue MCQs

Priority Queue and De Queue MCQs

 Q1. What is the time complexity to insert a node based on key in a priority queue?. 

A. O(nlogn). 

B. O(logn). 

C. O(n). 

D. O(n2). 

Answer= O(n)


Q2. What is not a disadvantage of priority scheduling in operating systems?. 

A. A low priority process might have to wait indefinitely for the CPU. 

B. If the system crashes, the low priority systems may be lost permanently. 

C. Interrupt handling. 

D. None of the mentioned. 

Answer= Interrupt handling


Q3. What are the advantages of priority queues?. 

A. Easy to implement. 

B. Processes with different priority can be efficiently handled. 

C. Applications with differing requirements. 

D. All of the mentioned. 

Answer= All of the mentioned


Q4.  What is the time complexity to insert a node based on position in a priority queue?. 

A. O(nlogn). 

B. O(logn). 

C. O(n). 

D. O(n2). 

Answer= O(n)


Q5. What is a dequeue?. 

A. A queue with insert/delete defined for both front and rear ends of the queue. 

B. A queue implemented with a doubly linked list. 

C. A queue implemented with both singly and doubly linked lists. 

D. None of the mentioned. 

Answer= A queue with insert/delete defined for both front and rear ends of the queue


Q6. What are the applications of dequeue?. 

A. A-Steal job scheduling algorithm. 

B. Can be used as both stack and queue. 

C. To find the maximum of all sub arrays of size k. 

D. All of the mentioned. 

Answer= All of the mentioned


Q7. What is the time complexity of deleting from the rear end of the dequeue implemented with a singly linked list?. 

A. O(nlogn). 

B. O(logn). 

C. O(n). 

D. O(n2). 

Answer= O(n)


Q8. A Double-ended queue supports operations such as adding and removing items from both the sides of the queue. They support four operations like addFront(adding item to top of the queue), addRear(adding item to the bottom of the queue), removeFront(removing item from the top of the queue) and removeRear(removing item from the bottom of the queue). You are given only stacks to implement this data structure. You can implement only push and pop operations. What are the total number of stacks required for this operation?(you can reuse the stack). 

A. 1. 

B. 2. 

C. 3. 

D. 4. 

Answer= 2


Q9. You are asked to perform a queue operation using a stack. Assume the size of the stack is some value 'n' and there are 'm' number of variables in this stack. The time complexity of performing de

Que operation is (Using only stack operations like push and pop)(Tightly bound).. 

A. O(m). 

B. O(n). 

C. O(m*n). 

D. Data is insufficient. 

Answer= O(m)


Q10. Consider you have an array of some random size. You need to perform dequeue operation. You can perform it using stack operation (push and pop) or using queue operations itself (en

Que and Dequeue). The output is guaranteed to be same. Find some differences?. 

A. They will have different time complexities. 

B. The memory used will not be different. 

C. There are chances that output might be different. 

D. No differences. 

Answer= They will have different time complexities


Q11. A double-ended queue supports operations like adding and removing items from both the sides of the queue. They support four operations like addFront(adding item to top of the queue), addRear(adding item to the bottom of the queue), removeFront(removing item from the top of the queue) and removeRear(removing item from the bottom of the queue). You are given only stacks to implement this data structure. You can implement only push and pop operations. What's the time complexity of performing addFront and addRear? (Assume 'm' to be the size of the stack and 'n' to be the number of elements). 

A. O(m) and O(n). 

B. O(1) and O(n). 

C. O(n) and O(1). 

D. O(n) and O(m). 

Answer= O(1) and O(n)


Q12. Why is implementation of stack operations on queues not feasible for a large dataset (Asssume the number of elements in the stack to be n)?. 

A. Because of its time complexity O(n). 

B. Because of its time complexity O(log(n)). 

C. Extra memory is not required. 

D. There are no problems. 

Answer= Because of its time complexity O(n)


Q13. Consider yourself to be in a planet where the computational power of chips to be slow. You have an array of size 10.You want to perform enqueue some element into this array. But you can perform only push and pop operations .Push and pop operation both take 1 sec respectively. The total time required to perform en

Que operation is?. 

A. 20. 

B. 40. 

C. 42. 

D. 43. 

Answer= 43


Q14. You have two jars, one jar which has 10 rings and the other has none. They are placed one above the other. You want to remove the last ring in the jar. And the second jar is weak and cannot be used to store rings for a long time.. 

A. Empty the first jar by removing it one by one from the first jar and placing it into the second jar. 

B. Empty the first jar by removing it one by one from the first jar and placing it into the second jar and empty the second jar by placing all the rings into the first jar one by one. 

C. There exists no possible way to do this. 

D. Break the jar and remove the last one. 

Answer= Empty the first jar by removing it one by one from the first jar and placing it into the second jar and empty the second jar by placing all the rings into the first jar one by one


Q15. Given only a single array of size 10 and no other memory is available. Which of the following operation is not feasible to implement (Given only push and pop operation)?. 

A. Push. 

B. Pop. 

C. Enqueue. 

D. Returntop. 

Answer= Enqueue


Q16. Given an array of size n, let's assume an element is 'touched' if and only if some operation is performed on it(for example, for performing a pop operation the top element is 'touched'). Now you need to perform Dequeue operation. Each element in the array is touched atleast?. 

A. Once. 

B. Twice. 

C. Thrice. 

D. Four times. 

Answer= Four times


Q17. How many stacks are required for applying evaluation of infix expression algorithm?. 

A. one. 

B. two. 

C. three. 

D. four. 

Answer= two


Q18. How many passes does the evaluation of infix expression algorithm makes through the input?. 

A. One. 

B. Two. 

C. Three. 

D. Four. 

Answer= One

Previous Post Next Post