SUMMER TRAINING Free Tutorials  Go To Your University  Placement Preparation 
Project Based Best Summer Training Courses in Jaipur
Join our Telegram Channel To take free Online Courses
0 like 0 dislike
85 views
in Examples, Exercises and Projects by (562 points)
edited by

Here, you will know various types of numericals and solutions to it.

1 Answer

0 like 0 dislike
by (562 points)
selected by
 
Best answer

Conversion of infix expression to prefix expression

P) (A+B) *C

Solution:

⇒[+AB]*C

⇒*+ABC

P:2) (A-B) *(C+D) 

Solution:

⇒[-AB]*[+CD]

⇒*-AB+CD

P:3) (A+B) /(C+D) -(D*E) 

Solution:

⇒[+AB]/[+CD]-[*DE]

⇒[/+AB+CD]-[*DE]

⇒-/+AB+CD*DE


  1. Convert the expression given below into its equivalent prefix and postfix notation. 

((A+B) ^C) -(D-E) ^(F+G)) 

Prefix notation:

(​​​​[+AB]^C-[-DE]^[+FG]) 

⇒-^ABC ^ -DE+FG

Postfix Notation:

⇒AB+C^DE-FG+^-


  1. Evaluate the following postfix expressions for A=2, B=5, C=3, D=2, E=4

ABC+DE*/-

Show stack at each step. 

Solution:

ABC+DE*/-

Given, A=2, B=5, C=3, D=2, E=4

So, putting values of A, B, C, D, E into the above expression , we get

2 5 3+2 4 * / - 

Symbol Scanned Stack
(1)                 2 2
(2)                 5 2, 5
(3)                 3 2, 5,3
(4)                 + 2,8
(5)                 2 2, 8,2
(6)                 4 2, 8,2,4
(7)                 * 2, 8,8
(8)                 / 2, 1
(9)                - 1

So, the final number in stack is 1, which is the solution. 


  1. Transform the following expression into its equivalent postfix expression using stack. 

A+(B*C-(D/E↑) *G) *H) 

Solution:

Symbol Scanned Stack Expression
(1)         A ( A
(2)         + (+ A
(3)        ( (+( A
(4)        B (+( AB
(5)        * (+(* AB
(6)        C (+(* ABC
(7)       - (+(- ABC*
(8)       ( (+(-( ABC*
(9)        D (+(-( ABC*D
(10)      / (+(-(/ ABC*D
(11)      E (+(-(/ ABC*DE
(12)      ↑ (+(-(/↑ ABC*DE
(13)      F (+(-(/↑ ABC*DEF
(14)     )  (+(- ABC*DEF↑/
(15)      * (+(-* ABC*DEF↑/
(16)      G (+(-* ABC*DEF↑/G
(17)      )  (+ ABC*DEF↑/G*-
(18)      * (+* ABC*DEF↑/G*-
(19)     H (+* ABC*DEF↑/G*-H
(20)     )  ABC*DEF↑/G*-H*+

The equivalent postfix expression of the above infix expression is: 

ABC*DEF↑/G*-H*+


  1. Calculate the position of element which is present in 7th row and 8th column for a 10×10 matrix . Here base address is 6010.

Solution:

By row major order:

 Address[aij] =M+(i-1) ×n+j-1

⇒a78=6010+(7-1) ×10+8-1

⇒a78=6077

By coulmn major order:

Address[aij]=M+(j-1) ×m+i+1

⇒a78=6010+(8-1) ×10+7-1

⇒a78=6086


Our Mentors(For AI-ML)


Sharda Godara Chaudhary

Mrs. Sharda Godara Chaudhary

An alumna of MNIT-Jaipur and ACCENTURE, Pune

NISHA (IIT BHU)

Ms. Nisha

An alumna of IIT-BHU

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...