COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
1
|
|
2
|
|
3
|
|
4
|
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 is a function in stack definition which is used to insert data at the stack’s top. Given below is the syntax of the push function in the stack. Pop is a function in the stack definition which is used to remove data from the stack’s top. Given below is the syntax of the pop function in the stack.
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: -Basic Operations on Stack top() Returns the top element of the stack. isEmpty() returns true if stack is empty else false. size() returns the size of stack.