# YOU CAN DOWNLOAD 200+ SUBJECTS PDF BOOK FOR COMPETITIVE EXAMINATIONS

## Evaluation of a Prefix Expression Multiple choice Questions and Answers (MCQs)

Question 6 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Find the output of the following prefix expression

*+2-2 1/-4 2+-5 3 1

2 | |

12 | |

10 | |

4 |

Question 6 Explanation:

The given prefix expression is evaluated using two stacks and the value is given by (2+2-1)*(4-2)/(5-3+1)= 2.

Question 7 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

An error is thrown if the character '\n' is pushed in to the character stack.

true | |

false |

Question 7 Explanation:

The input character '\n' is accepted as a character by the evaluation of prefix expression algorithm.

Question 8 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Using the evaluation of prefix algorithm, evaluate +-9 2 7.

10 | |

4 | |

17 | |

14 |

Question 8 Explanation:

Using the evaluation of prefix algorithm, +-9 2 7 is evaluated as 9-2+7=14.

Question 9 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

If -*+abcd = 11, find a, b, c, d using evaluation of prefix algorithm.

a=2, b=3, c=5, d=4 | |

a=1, b=2, c=5, d=4 | |

a=5, b=4, c=7, d=5 | |

a=1, b=2, c=3, d=4 |

Question 9 Explanation:

The given prefix expression is evaluated as ((1+2)*5)-4 =11 while a=1, b=2, c=5, d=4.

Question 10 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

In the given C snippet, find the statement number that has error.

//C code to push an element into a stack

1. void push( struct stack *s, int x) 2. { 3. if(s->top==MAX-1) 4. { 5. printf("stack overflow"); 6. } 7. else 8. { 9. s->items[++s->top]=x; 10. s++; 11. } 12.}

1 | |

9 | |

10 | |

11 |

Question 10 Explanation:

The stack's top position is incremented twice at the same time. So, when the next element is pushed, there is unit gap between this element and the previous element.

There are 10 questions to complete.