What does ‘stack underflow’ refer to?

a) accessing item from an undefined stack

b) adding items to a full stack

c) removing items from an empty stack

d) index out of bounds exception

Option: c

Explanation: Removing items from an empty stack is termed as stack underflow.

What is the time complexity of pop() operation when the stack isimplemented

using an array?

a) O(1)

b) O(n)

c) O(logn)

d) O(nlogn)

Option: a

Explanation: pop() accesses only one end of the structure, and hence constant time.

)Which of the following array position will be occupied by a new element being

pushed for a stack of size N elements(capacity of stack > N).

a) S[N-1]

b) S[N]

c) S[1]

d) S[0]

Option: b

Explanation: Elements are pushed at the end, hence N.

What happens when you pop from an empty stack while implementing using the

Stack ADT in Java?

a) Undefined error

b) Compiler displays a warning

c) EmptyStackException is thrown

d) NoStackException is thrown

Option: c

Explanation: The Stack ADT throws an EmptyStackException if the stack is empty

and a pop() operation is tried on it.

Which of the following array element will return the top-of-the-stack-element for a

stack of size N elements(capacity of stack > N).

a) S[N-1]

b) S[N]

c) S[N-2]

d) S[N+1]

Option: a

Explanation: Array indexing start from 0, hence N-1 is the last index.

Which one ofthe following is an application of Stack Data Structure?

a) g function calls

b) e stock spanproblem

c) c expression evaluation

d) l the above

Option: A

The data structure required to check whether an expression contains balanced

parenthesis is?

a) Stack

b) Queue

c) Array

d) Tree

Option : a

The postfix form of A*B+C/D is?

a) *AB/CD+

b) AB*CD/+

c) A*BC+/D

d) ABCD+/*

Option : B

Which data structure is needed to convert infix notation to postfix notation?

a) Branch

b) Tree

c) Queue

d) Stack

Option : d

The prefix form of A-B/ (C * D ⋀ E) is?

a) -/*⋀ACBDE

b) -ABCD*⋀DE

c) -A/B*C⋀DE

d) -A/BC*⋀DE

Option : c

The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?

a) 600

b) 350

c) 650

d) 588

Option : b

Consider the linked list implementation of a stack. Which of the following node

is considered as Top of the stack?

a) First node

b) Last node

c) Any node

d) Middle node

Option : a

Consider the following operation performed on a stack of size 5.

Push(1);

Pop();

Push(2);

Push(3);

Pop();

Push(4);

Pop();

Pop();

Push(5);

After the completion of all operation, the no of element present on stack are

a) 1

b) 2

c) 3

d) 4

Option : a

Which of the following is not an inherent application of stack?

a) Reversing a string

b) Evaluation of postfix expression

c) Implementation of recursion

d) Job scheduling

Option : d

Which of the following operation take worst case linear time in the array

implementation of stack?

a) Push

b) Pop

c) IsEmpty

d) None

Option : d

Which of the following application generally use a stack?

a) Parenthesis balancing program

b) Syntax analyzer in compiler

c) Keeping track of local variables at run time

d) All of the above

Option : d

What is the minimum number of stacks of size n required to implement a

queue of size n?

a) One

b) Two

c) Three

d) Four

Option : b

Consider the usual implementation of parentheses balancing program using

stack. What is the maximum number of parentheses that will appear on stack at

any instance of time during the analysis of ( ( ) ( ( ) ) ( ( ) ) )?

a) 1

b) 2

c) 3

d) 4

Option : c