MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
User perform following operations on stack of size 5 then-push(1);pop();push(2);push(3);pop();push(2);pop();pop();push(4);pop();pop();push(5);
A
Overflow Occurs
B
Stack Operations will be performed Smoothly
C
Underflow Occurs
D
None of these
Explanation: 

Detailed explanation-1: -Answer: Option A is correct. Hence, only one element is present in the stack which is 5. Thus finally only one element is is in stack i.e., 5.

Detailed explanation-2: -Push operation refers to inserting an element in the stack. Since there’s only one position at which the new element can be inserted-Top of the stack, the new element is inserted at the top of the stack. POP Operation. Pop operation refers to the removal of an element.

Detailed explanation-3: -What is the time complexity of pop() operation when the stack is implemented using an array? Explanation: pop() accesses only one end of the structure, and hence constant time.

Detailed explanation-4: -Stack. push(E element) method is used to push an element into the Stack. The element gets pushed onto the top of the Stack. Parameters: The method accepts one parameter element of type Stack and refers to the element to be pushed into the stack.

There is 1 question to complete.