Suppose a circular queue of capacity n − 1 elements is implemented with an array of n elements. Insertion and deletion use REAR and FRONT as array index variables 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
One slot is kept empty: the queue is empty when REAR == FRONT and full when advancing REAR would make it equal to 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: AVL trees are more balan…
- Consider a hash table of size 7 with starting index 0 and hash function (6x + 3) mod 4. Assuming the table is initially empty, which of the…
- Match List I with List IIList I List II A. Running time of a straightforward recursive method to compute the nth Fibonacci number Fₙ I. O(n…
- Statement I: If f and g are two functions and f = O(g) but g ≠ o(f), we say that the growth rate of g is smaller than that of f. Statement…
- 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…
- For each function below, let n be the least integer such that f(x) is O(xⁿ). Arrange the functions in increasing order of n: A. f(x) = 3x³…