GATE Computer ScienceEasyGATE CS (PYQ pattern)
A circular queue of capacity 10 (array indices 0..9) keeps front and rear indices; front is the index of the first item and rear is the index of the next free slot, with one slot always kept empty. If front = 7 and rear = 3, how many items are in the queue, and how many more can be enqueued?
- A. 4 items and 5 more
- B. 6 items and 4 more
- C. 5 items and 4 more
- D. 6 items and 3 more
Correct answer: D. 6 items and 3 more
Items = (rear - front + 10) mod 10 = (3 - 7 + 10) mod 10 = 6. Capacity usable is 9, so 9 - 6 = 3 more.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- Convert the infix expression a - b c / d + e (f - g) / h (all binary operators left-associative; and / bind tighter than + and -) to…
- Evaluate the prefix expression - + 4 5 - 9 3 / 20 + 2 3 (integer division truncating toward zero).
- Under the uniform-hashing assumption, a linear-probing table has load factor 0.5. Using the Knuth approximations, the expected number of…
- In the BST built by inserting 40, 20, 60, 10, 30, 50, 70, 25, 35, 45, 55, 65, 75, 22 in order, what are the inorder successor of 35, the…
- int f(int n) { if (n == 0) return 1; return f(n - 1) + f(n - 1); } How many calls to f (including the first) does f(10) make?
- Keys 30, 10, 20, 50, 40, 60, 45 are inserted into an initially empty AVL tree in this order. What are the root and the total number of…