MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, in what order will they be removed?
A
ABCD
B
DCBA
C
DCAB
D
ABDC
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: -In a stack, adding and removing of elements are performed at single position which is known as “top". That means, new element is added at top of the stack and an element is removed from the top of the stack. In stack, the insertion and deletion operations are performed based on LIFO (Last In First Out) principle.

Detailed explanation-3: -You can access only the top of the stack at any given point in time. Inserting a new element in the stack is termed a push operation. Removing or deleting elements from the stack is termed pop operation.

Detailed explanation-4: -Deletion of an element from the top of the stack is called pop operation. The value of the variable top will be incremented by 1 whenever an item is deleted from the stack.

Detailed explanation-5: -Underflow Condition: When a stack is empty (i.e. TOP=-1) and we try to delete more element from it, then this condition is called underflow condition.

There is 1 question to complete.