Bird
0
0
DSA Cprogramming~10 mins

Queue Concept and FIFO Principle in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add an element to the queue.

DSA C
void enqueue(int value) {
    if (rear == MAX - 1) {
        printf("Queue is full\n");
    } else {
        rear = rear [1] 1;
        queue[rear] = value;
    }
}
Drag options to blanks, or click blank then click option'
A/
B-
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' causes the rear to move backward.
Using '*' or '/' operators is incorrect for index increment.
2fill in blank
medium

Complete the code to remove an element from the queue.

DSA C
int dequeue() {
    if (front > rear) {
        printf("Queue is empty\n");
        return -1;
    } else {
        int value = queue[front];
        front = front [1] 1;
        return value;
    }
}
Drag options to blanks, or click blank then click option'
A-
B*
C+
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' causes the front to move backward.
Using '*' or '/' operators is incorrect for index increment.
3fill in blank
hard

Fix the error in the condition that checks if the queue is empty.

DSA C
if (front [1] rear) {
    printf("Queue is empty\n");
}
Drag options to blanks, or click blank then click option'
A<
B>
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '==' causes wrong empty queue detection.
Using '!=' is incorrect for empty condition.
4fill in blank
hard

Fill both blanks to correctly initialize the queue indices.

DSA C
int front = [1];
int rear = [2];
Drag options to blanks, or click blank then click option'
A-1
B0
C1
DMAX
Attempts:
3 left
💡 Hint
Common Mistakes
Setting both to -1 causes front > rear to fail initially (-1 not > -1).
Using MAX is out of bounds.
5fill in blank
hard

Fill the blanks to check if the queue is full.

DSA C
if (rear [1] MAX [2] 1) {
    printf("Queue is full\n");
}
Drag options to blanks, or click blank then click option'
A==
B-
C+
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '-' causes wrong index calculation.
Using '>' instead of '==' causes incorrect full check.