Dharma Previous Years Solved Sample Placement Papers
-
What data structure is used when converting an infix notation to prefix notation?
(a) Stack
(b) Queue
(c) B-Trees
(d) Linked-list
Answer: (a)
Explanation: To convert infix to prefix, reverse the equation and use the infix-to-postfix algorithm. This process utilizes stacks for operator precedence and association. -
What would be the Prefix notation for the given equation?
A+(B*C)
(a) +A*CB
(b) *B+AC
(c) +A*BC
(d) *A+CB
Answer: (c)
Explanation: Reverse the equation or scan from right to left. Apply the infix-to-postfix algorithm. Inside the brackets, the result isCB*
, and outside the brackets, it isA+
. Reversing gives+A*BC
. -
What would be the Prefix notation for the given equation?
(A*B)+(C*D)
(a) +*AB*CD
(b) *+AB*CD
(c) **AB+CD
(d) +*BA*CD
Answer: (a)
Explanation: Reverse the equation or scan from right to left. Apply the infix-to-postfix algorithm. Brackets evaluate toDC*
andBA*
, resulting in+*AB*CD
after reversal. -
What would be the Prefix notation for the given equation?
A+B*C^D
(a) +A*B^CD
(b) +A^B*CD
(c) *A+B^CD
(d) ^A*B+CD
Answer: (a)
Explanation: Reverse the equation or scan from right to left. Apply the infix-to-prefix algorithm. The order of precedence is+*
and^
. The reversed expression evaluates to+A*B^CD
. -
Out of the following operators (
^
,*
,+
,&
,$
), the one having the highest priority is?
(a) +
(b) $
(c) ^
(d) &
Answer: (c)
Explanation: According to the infix-to-prefix algorithm, exponentiation (^
) has the highest priority among the given operators. -
Out of the following operators (
|
,*
,+
,&
,$
), the one having the lowest priority is?
(a) +
(b) $
(c) |
(d) &
Answer: (c)
Explanation: Logical OR (|
) has the lowest precedence among the given operators, as defined in the infix-to-prefix algorithm. -
What would be the Prefix notation for the given equation?
A^B^C^D
(a) ^^^ABCD
(b) ^A^B^CD
(c) ABCD^^^
(d) AB^C^D
Answer: (a)
Explanation: Reverse the equation or scan from right to left. The exponentiation operator has right-to-left associativity, so all operators are pushed onto the stack, resulting in^^^ABCD
. -
What would be the Prefix notation for the given equation?
a+b-c/d&e|f
(a) |&-+ab/cdef
(b) &|-+ab/cdef
(c) |&-ab+/cdef
(d) |&-+/abcdef
Answer: (a)
Explanation: Reverse the equation or scan from right to left. The precedence order is| & + /
. Operators are pushed and popped based on precedence, resulting in|&-+ab/cdef
. -
What would be the Prefix notation for the given equation?
(a+(b/c)*(d^e)-f)
(a) -+a*/^bcdef
(b) -+a*/bc^def
(c) -+a*b/c^def
(d) -a+*/bc^def
Answer: (b)
Explanation: Reverse the equation or scan from right to left. Solve equations within brackets first. The precedence order is+*/^
, resulting in-+a*/bc^def
. -
What would be the Prefix notation and Postfix notation for the given equation?
A+B+C
(a) ++ABC and AB+C+
(b) AB+C+ and ++ABC
(c) ABC++ and AB+C+
(d) ABC+ and ABC+
Answer: (a)
Explanation: Prefix notation places operators before their operands, resulting in++ABC
. Postfix notation places operators after their operands, resulting inAB+C+
.