1) Which of the following statement(s) about stack data structure is/are NOT correct?
Ans: Stack is the FIFO data structure
2) What are the disadvantages of arrays?
Ans: All of the mentioned
3) Which of these unbalanced sequences does the above code think is balanced?
Ans: ((())
4) Which data structure is needed to convert infix notation to postfix notation?
Ans: Stack
5) Consider an array consisting of –ve and +ve numbers. What would be the worst time comparisons an algorithm can take in order to segregate the numbers having same sign altogether i.e all +ve on one side and then all -ve on the other ?
Ans: N-1
6) Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(())) are:
Ans: 3
7) Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c – d ^ e ^ f is
Ans: abc × + def ^ ^ –
8) Which of these best describes an array?
Ans: cin.get(ch)
9) When does the ArrayIndexOutOfBoundsException occur?
Ans: Run-time
10) The postfix form of the expression (A+ B)*(C*D- E)*F / G is ?
Ans: AB+ CD*E – FG /**
11) Which of the following operations is not O(1) for an array of sorted data. You may assume that array elements are distinct?
Ans: Delete an element
12) In a stack, if a user tries to remove an element from empty stack it is called _________
Ans: Underflow
13) Comment on the following statement: int (*a)[7];
Ans: A pointer “a” to an array.
14) Comment on the 2 arrays regarding P and Q:
int *a1[8];
int *(a3[8]); (code-box)
P. Array of pointers
Q. Pointer to an array
Ans: a1 is P, a2 is P
15) Which of the following applications may use a stack?
Ans: All of the mentioned