Suppose that a stack object contains the following values Top {8, 5, 2, 9} Botto
ID: 3817775 • Letter: S
Question
Suppose that a stack object contains the following values Top {8, 5, 2, 9} Bottom push (3) What is the contents of The stack after the following operation? Top {8, 5, 2, 9} Bottom Top {3, 8, 5, 2, 9} Top {5, 2, 9} Bottom Top {8, 5, 2, 9, 3} None of the answers provided Suppose that a stack object contains the following values Top {8, 5, 2, 9} Bottom. What is the contents of the stack after the following operation? POP () Top {8, 5, 2} Bottom Top {8, 5, 2, 9} Bottom Top {5, 2, 9} Bottom Top {} Bottom None of the answers provided Suppose that a stack object contains the following values Top {8, 5, 2, 9} Bottom. What is the contents of the stack after the following sequence of operations are executed left-to-right? Push(3), pop() Top {3, 8, 5, 2, 9} Bottom Top {8, 5, 2, 9, 3} Bottom Top {5, 2, 9, 3} Bottom Top {3, 8, 5, 2} Bottom None of the answers provided Suppose that a stack object contains the following values Top {8, 5, 2, 9} Bottom What is the contents of the stack after the following sequence of operations are executed left-to-right? Pop()Push (3) Top {5, 2, 9, 3} Bottom Top {3, 8, 5, 2} Top {3, 5, 2, 9} Top {3, 8, 5, 2, 9} Bottom None of the answers provided What is the complexity of the Make Empty () operation for the linked node Stack implementation? O(1) O(N) O(log N) O(N^2) None of the answers providedExplanation / Answer
Stack is a LIFO i.e. last in first in structure. In which elements are inserted at top of stack.
pop() delete the element at top of the stack.
push() insert element at top of the stack.
1) Answer:B)Top{3,8,5,2,9}Bottom
Initially stack is Top{8,5,2,9}Bottom. After push(3) the element 3 is inserted at top of stack and stack becomes
Top{3,8,5,2,9}Bottom.
2) Answer:C) Top{5,2,9}Bottom
Initially stack is Top{8,5,2,9}Bottom. After pop() the top element i.e. 8 is deleted from top of stack and stack becomes Top{5,2,9}Bottom.
3)Answer:E)None of the answers provided.
Initially stack is Top{8,5,2,9}Bottom. After push(3) the element 3 is inserted at top of stack and stack becomes
Top{3,8,5,2,9}Bottom. Then pop() delete the top element i.e. 3 therefore stack becomes Top{8,5,2,9}Bottom. Therefore answer is C.
4) Answer: C) Top{3,5,2,9}Bottom
Initially stack is Top{8,5,2,9}Bottom. First After pop() delete the top element i.e. 8 therefore stack becomes Top{5,2,9}Bottom. Then push(3) inserts element 3 in stack and stack becomes Top{3,5,2,9}Bottom. Therefore answer is C.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.