Computer Science EngineeringVery hard
A queue starts empty. Operations: enqueue 1, enqueue 2, enqueue 3, dequeue, enqueue 4, dequeue, enqueue 5. Which element is now at the front?
- A. 2
- B. 3
- C. 4
- D. 5
Correct answer: B. 3
After two dequeues the elements 1 and 2 are gone, leaving 3, 4, 5 with 3 at the front.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- The textbook minimum number of stacks needed to implement a queue is
- In a binary search tree, the inorder successor of a node that has a non-empty right subtree is
- Keys 50, 30, 70, 20, 40, 60, 80 are inserted into an empty BST in this order. The postorder traversal is
- A directed acyclic graph has n vertices. How many strongly connected components does it have?
- What is the minimum number of coins needed to make 11 using denominations {1, 5, 6, 9}?
- Huffman coding is applied to frequencies 5, 9, 12, 13, 16, 45. What is the total weighted path length (sum of internal node weights)?