MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
While implementing Stack using list when we want to delete element we must use pop function as ____
A
list.pop(0)
B
list.pop(pos)
C
list.pop()
D
list.pop(1)
Explanation: 

Detailed explanation-1: -In stack, the insertion and deletion operations are performed based on LIFO (Last In First Out) principle.

Detailed explanation-2: -A stack is an ordered list in which all insertions and deletions are made at one end, called the top. A queue is an ordered list in which all insertions take place at one end, the rear, while all deletions take place at the other end, the front.

Detailed explanation-3: -Python stack can also be implemented using the deque class from the collections module. Deque is preferred over list in cases where we need to quickly append and pop operations from both the ends of the container.

There is 1 question to complete.