Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

01. Suppose that a stack contains the following values Topf7, 5, 2, 9 } Bottom W

ID: 3701793 • Letter: 0

Question

01. Suppose that a stack contains the following values Topf7, 5, 2, 9 } Bottom What is the contents of the stack after the following operation? A) Top {7, 5, 2, 9) Bottom B) Top 1, 7, 5, 2, 9) Bottom C) Top f5, 2, 9} Bottom Push(1) D) Top f7, 5, 2, 9,1} Bottom E) None of the answers provided 02. Suppose that a stack contains the following values Topf7, 5, 2, 9 } Bottom What is the contents of the stack after the following operation (x is int)? A) Top {7, 5, 2} Bottom B) Top 7, 5, 2, 9) Bottom C) Top { ) Bottom Pop(x) D) Top f5, 2,9} Bottom E) None of the answers provided 03. Suppose that a stack contains the following values Topf7, 5, 2, 9 } Bottom What is the contents of the stack after the following sequence of operations are executed left-to-right (x is int)? Push(1), Pop(x) A) Top {1, 7, 5, 2,9} Bottom B) Top 7, 5, 2, 9,1} Bottom C) Top f5, 2, 9,1 Bottom D) Top f1, 7, 5, 2) Bottom E) None of the answers provided 04. Suppose that a stack contains the following values Topf7, 5, 2, 9 } Bottom What is the contents of the stack after the following sequence of operations are executed left-to-right (x is int)? Pop(x), Push(1) A) Top f5, 2, 9,1) Bottom B) Top 1,7, 5,2) Bottom C) Top 1, 5, 2, 9} Bottom D) Top f1, 7, 5, 2,9} Bottom E) None of the answers provided 05. What is the complexity of the MakeEmpty() operation for the linked node Stack implementation? C) O(logN) E) None of the answers provided B) O(N D) O(N2)

Explanation / Answer

1. Stack: TOP {7, 5, 2, 9 } BOTTOM

Operation: Push(1)

Stack works on First In Last Out principle, So after performing Push(1) operation on given stack the output will be.

Output:
B) TOP {1, 7, 5, 2, 9} BOTTOM


2. Stack: TOP {7, 5, 2, 9 } BOTTOM

Operation: Pop(x)

After performing Pop(x) operation on given stack, it will remove a top element and the output will be.

Output:
B) TOP { 5, 2, 9} BOTTOM


3. Stack: TOP {7, 5, 2, 9 } BOTTOM

Operation: Push(1), Pop(x)

After performing Push(1) and Pop(x) operation on given stack, it will push element 1 on the top of the stack and after performing Pop it will remove top element i.e 1 from the stack.
So the output will remain same i.e TOP {7, 5, 2, 9 } BOTTOM and it is not in options

Output:
E) None of the answers provided

4. Stack: TOP {7, 5, 2, 9 } BOTTOM

Operation: Pop(x), Push(1)

After performing Pop(x) and Push(1) operation on given stack, it will (pop) remove top element from stack i.e 7 and push 1 on the top of the stack. So the output will be TOP {1, 5, 2, 9 } BOTTOM

Output:
C) TOP {1, 5, 2, 9 } BOTTOM

5. The complexity of the MakeEmpty() operation for the linked node Stack implementation is O(N)

B) O(N)