Suppose a circular queue of capacity n-1 elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variable respectively. Initially, REAR = FRONT =0. The conditions to detect queue empty and queue full are
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: A. EMPTY: REAR == FRONT FULL: ( REAR +1 ) mod n == FRONT
Explanation
Leaving one slot empty: the queue is empty when REAR == FRONT and full when (REAR + 1) mod n == FRONT.
More Data Structures and Algorithms questions
- Given below are two statements: one is labelled as Assertion A and the other is labelled as Reason R. Assertion A: The AVL trees are more b…
- Consider a hash table of size seven with starting (6x + 3) mod 4 index zero and a hash function . Assuming the hash table is initially empt…
- Match List I with List II
- Given below are two statements: Statement I: If f and g are two functions and f = O(g) g ≠ o(f) but , we say that the growth rate of g is s…
- Given below are two statements: one is labelled as Assertion A and the other is labelled as Reason R. Assertion A: It is possible to create…
- Given six weights 4, 15, 25, 5, 8, 16, construct a 2-tree (binary tree). What is the minimum weighted path length?