MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
If letter ‘D’, ‘C’, ‘B’, ‘A’, are sequentially inserted into a queue, and then deleted one by one, in which sequence will the letter be deleted from the queue?
A
A, B, C, D
B
A, B, D, C
C
D, C, A, B
D
D, C, B, A
Explanation: 

Detailed explanation-1: -If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed? Explanation: Queue follows FIFO approach. i.e. First in First Out Approach. So, the order of removal elements are ABCD.

Detailed explanation-2: -Dequeue Operation Dequeue means removing an element from the queue. Since queue follows the FIFO principle we need to remove the element of the queue which was inserted at first.

Detailed explanation-3: -Insertion and deletion in queues takes place from the opposite ends of the list. The insertion takes place at the rear of the list and the deletion takes place from the front of the list. Insert operation is called push operation. Insert operation is called enqueue operation. Delete operation is called pop operation.

Detailed explanation-4: -The insertion of an element in a queue is called an enqueue operation and the deletion of an element is called a dequeue operation.

Detailed explanation-5: -A queue is based on first in first out (FIFO) property i.e. element inserted first will be the first one to be deleted.

There is 1 question to complete.