In this Blog we are providing all the UGC-NET Computer Science previous year Questions with explanation:
Q:3 Given an empty stack, after performing push(1), push(2), Pop, push(3), push(4), Pop, Pop, push(5),Pop, what is the value of the top of the stack?
(A) 4
(B) 3
(C) 2
(D) 1
(UGC-NET Computer Science December 2012)
Answer: (D)
Explanation:
An empty stack will look like this:
After performing Push(1):
1 will be on TOP.
2 will be on TOP.
Again 1 will be on TOP.
After performing POP, POP:
Q:3 Given an empty stack, after performing push(1), push(2), Pop, push(3), push(4), Pop, Pop, push(5),Pop, what is the value of the top of the stack?
(A) 4
(B) 3
(C) 2
(D) 1
(UGC-NET Computer Science December 2012)
Answer: (D)
Explanation:
An empty stack will look like this:
After performing Push(1):
1 |
---|
1 will be on TOP.
After performing Push(2):
2 |
---|
1 |
2 will be on TOP.
After performing POP:
1 |
---|
Again 1 will be on TOP.
After performing Push(3), Push(4):
4 |
---|
3 |
1 |
After performing POP, POP:
1 |
---|
1 will be on TOP.
After performing Push(5), POP again 1 will be on TOP of the Stack. Hence option (D) is Correct.
This question was taken from UGC-NET Computer Science December 2012.
No comments:
Post a Comment