Question 1
What is the best data structure to implement a queue?
1
Array
2
Tree
3
Stack
4
Linked List
Question 2
Which type of queue allows insertion is limited to one end, while deletion is allowed from both ends.?
1
Priority queue
2
Input-restricted deque
3
Circular queue
4
Deque
Question 3
What is the time complexity of enqueuing an element in a circular queue (using an array)?
1
O(log n)
2
O(n)
3
O(n log n)
4
O(1)
Question 4
What is the difference between a queue and a priority queue?
1
A queue follows FIFO, but a priority queue does not
2
A priority queue always has O(1) enqueue time
3
Elements are sorted in a queue, but not in a priority queue
4
None of the above
Question 5
The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is
1
D
2
B
3
C
4
A
Question 6
How would you implement the A* search algorithm for pathfinding in a graph?
1
Use a stack to store nodes
2
Use recursion to explore all paths
3
Use a simple list to store nodes
4
Use a priority queue to store nodes