GATE Computer ScienceVery hardGATE CSE · NIELIT
A circular queue uses an array of size 8 with indices 0–7. Initially front = rear = 0. Enqueue: if (rear+1) mod 8 == front the queue is full and the operation is rejected, else rear = (rear+1) mod 8 and store. Dequeue: if front == rear it is empty and rejected, else front = (front+1) mod 8. The operations are E1 E2 E3 E4 E5 D E6 E7 E8 E9 E10 D D D E11 E12 D E13 E14 E15 E16 D (Ek enqueues item k, D dequeues). After all operations, what is the pair (front, rear)?
- A. (0, 5)
- B. (7, 6)
- C. (6, 4)
- D. (7, 5)
Correct answer: D. (7, 5)
Simulating the 23 operations (3 rejected as full or empty) leaves front = 7, rear = 5 and 6 items queued.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A directed graph on vertices 1–8 has adjacency lists 1:[2,5]; 2:[3,6]; 3:[4,1]; 4:[2,7]; 5:[6,4]; 6:[7]; 7:[5,8]; 8:[3,6]. DFS starts at…
- Strings X = ABCBDABA and Y = BDCABAB are given. How many distinct longest common subsequences (distinct as strings) do they have?
- Words car, card, care, cart, cat, dog, door, dot, dove, do, cargo, carbon, catalog, cat are inserted into an initially empty trie (a…
- A B-tree of order 5 (each node holds at most 4 keys) is built by inserting 1, 2, 3, …, 60 in increasing order. When a node overflows to 5…
- How many different arrays A[1..9] that are permutations of {1,…,9} satisfy the min-heap property (A[i] ≥ A[⌊i/2⌋] for every i ≥ 2)?
- What is the minimum number of comparisons needed in the worst case to find both the maximum and the minimum of 101 distinct numbers using…