Bird
0
0
DSA Cprogramming~10 mins

Dequeue Operation 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 remove an element from the front of the dequeue.

DSA C
int dequeueFront() {
    if (front == -1) {
        return -1; // Dequeue is empty
    }
    int data = arr[front];
    if (front == rear) {
        front = rear = -1;
    } else {
        front = [1];
    }
    return data;
}
Drag options to blanks, or click blank then click option'
Arear - 1
Bfront - 1
Crear + 1
Dfront + 1
Attempts:
3 left
💡 Hint
Common Mistakes
Moving the front pointer backward instead of forward.
Changing the rear pointer instead of the front.
2fill in blank
medium

Complete the code to remove an element from the rear of the dequeue.

DSA C
int dequeueRear() {
    if (rear == -1) {
        return -1; // Dequeue is empty
    }
    int data = arr[rear];
    if (front == rear) {
        front = rear = -1;
    } else {
        rear = [1];
    }
    return data;
}
Drag options to blanks, or click blank then click option'
Arear - 1
Bfront + 1
Cfront - 1
Drear + 1
Attempts:
3 left
💡 Hint
Common Mistakes
Moving the rear pointer forward instead of backward.
Changing the front pointer instead of the rear.
3fill in blank
hard

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

DSA C
int isEmpty() {
    if ([1]) {
        return 1;
    }
    return 0;
}
Drag options to blanks, or click blank then click option'
Afront == rear
Bfront == 0 && rear == 0
Cfront == -1 && rear == -1
Dfront > rear
Attempts:
3 left
💡 Hint
Common Mistakes
Checking if front and rear are zero instead of -1.
Using front == rear which can be true when one element is present.
4fill in blank
hard

Fill both blanks to correctly update the front pointer in a circular dequeue after removing from front.

DSA C
void dequeueFrontCircular() {
    if (front == -1) {
        return; // Empty dequeue
    }
    if (front == rear) {
        front = rear = -1;
    } else {
        front = (front [1] 1) [2] size;
    }
}
Drag options to blanks, or click blank then click option'
A+
B-
C%
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition.
Using division instead of modulo for wrapping.
5fill in blank
hard

Fill all three blanks to correctly update the rear pointer in a circular dequeue after removing from rear.

DSA C
void dequeueRearCircular() {
    if (rear == -1) {
        return; // Empty dequeue
    }
    if (front == rear) {
        front = rear = -1;
    } else {
        rear = (rear [1] 1 + [2]) [3] size;
    }
}
Drag options to blanks, or click blank then click option'
A+
B-
Csize
D%
Attempts:
3 left
💡 Hint
Common Mistakes
Not adding size before modulo causing negative index.
Using addition instead of subtraction.