Infix to Postfix and Evalaution of postfix

Embed Size (px)

Citation preview

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    1/40

    Dsscfknbkt K` 4

    Ns. Dsowckc Daodib

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    2/40

      Cnpibnbkt stdhl ds dk dastrdht gdtdtypb usckf icklbg icst dkg usb tocsDGW j`r h`kvbrsc`k `j Ck!b!prbssc`k t` p`st! dkg bvdiudtc`k`j p`st! b!prbssc`k

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    3/40

    "tdhl ds dk DGW usckf#cklbg icst

    • #C$%

      #dst ck rst `ut

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    4/40

    typbgbj struht k`gb

    &

    hodr gdtd'  struht k`gb (kb!t'

    ) k`gb'

    gdtd Dggrbs

    s `jkbxtk`gb

    k`gb

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    5/40

    "WD*+ ds d DGW

    hidss "tdhl

    &

    k`gb (t`p'

    stdhl,- *`kstruht`r

    &t`p/K=##' ckctcdicb t`p ds K=## ckgchdtb

    stdhl cs bnpty

    )

    ckt csbnpty,-'

      v`cg puso,hodr !-'

      hodr p`p,-'

    )'

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    6/40

    *obhl 1npty

    ckt stdhl88csbnpty,-

    &

    cj,t`p//K=##-

    rbturk 4' trub

    rbturk 7' jdisb

    )

    t`p

    K=##

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    7/40

    puso,2d:-

    6`cg stdhl88puso,hodr !-

    &

    k`gb (p'

    p/kbw k`gb,-'

    p?3gdtd/!'

    p?3kb!t/t`p't`p/p'

    )

    d

    K=##

    p t`p

    t`p

    K=##5bj`rb

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    8/40

    puso,2a:-

    6`cg stdhl88puso,hodr !-

    &

    k`gb (p'

    p/kbw k`gb,-'

    p?3gdtd/!'

    p?3kb!t/t`p't`p/p'

    )

    d

    K=##

    t`pap

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    9/40

    puso,2h:-

    v`cg stdhl88puso,hodr !-

    &

    k`gb (p'

    p/kbw k`gb,-'

    p?3gdtd/!'

    p?3kb!t/t`p't`p/p'

    )

    d

    K=##

    t`p

    a

    p h

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    10/40

    2h:/

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    11/40

    2a:/

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    12/40

    2d:/

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    13/40

    Ck! t` p`st! *`kvbrstc`k

    4- Dhhbpt Ck! 1!prbssc`k9- "hdk ck! b!prbssc`k jr`n ibjt t` rcfot hodr ayhodr tcii 2>7: ,bkg `j strckf-

    ;- Cj hurrbkt hodr cs `pbrdkg

      n`vb todt t`lbk ck p`st! b!prbssc`k0- Cj *urrbkt hodr,t`lbk- cs `pbrdt`r

    hobhl prbhbgbkhb `j hurrbkt `pbrdt`r,t`lbk- dkg t`p `pbrdt`r`j stdhl

    • Cj prbhbgbkhb `j hurrbkt `pbrdt`r,t`lbk- 3 prbhbgbkhb `j

    t`p syna`i tobk puso t`lbk ckt` stdhl• 1isb cj prbhbgbkhb `j hurrbkt `pbrdt`r,t`lbk- M/ prbhbgbkhb

    `j t`p syna`i tobk p`p dii `pbrdt`r jr`n tob stdhl tciiprbhbgbkhb `j hurrbkt `pbrdt`r,t`lbk- 3 prbhbgbkhb `j t`psyna`i `r stdhl cs bnpty

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    14/40

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    15/40

    da(h?gj 2>7:1kg `j ck!

    b!prbssc`k

    gbhidrdtc`k

    hodr ck!;7B'

    4- Dhhbpt ck! b!prbssc`k

    h`ut99’Yk Bktbr Ckxbxprbssc`k„<

      hck;;ckx<  7 4 9 ; 0 J F O E

     L

    a( gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    16/40

    da(h?gj 2>7: L/7'

    stdhl s<

    j`r,c/7'ck!cBI/2>7:'c-&rbdg t`lbkhodr t`lbk/ck!cB'

    hobhl `pbrdt`r `r `pbrdkg

    cj,csdikun,t`lbk-- `pbrdkg&

    p`st!LB/t`lbk' L'

    )

    bisb&

    `pbrdt`r)

    )

    7 4 9 ; 0 J F O Ed

     L

    a( gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    17/40

    da(h?gj 2>7:`pbrdt`rbisb&

    cj(t`lbk>>‟(‟)s.puso,t`lbk-bisb

    cj(t`lbk>>‟))&

    wocib,,!/s.p`p,--I/2,2-

    p`st!LB/!')bisb&  !"c#b(prbhbgbkhb(t`lbk) 9> prbhbgbkhb(s$t`p%

    ;gdtd)) && 's$bpt())

      &  !/s.p`p,-'

    p`st!LB/!' L'

      )  s.puso,t`lbk-'

    )

    7 4 9 ; 0 J F O E

    d

     L

    a( gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    18/40

    da(h?gj 2>7:

     L

    7 4 9 ; 0 J F O E

    d a

    cj,csdikun,t`lbk-- `pbrdkg

    &p`st!LB/t`lbk'

     L')

    a( gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    19/40

    da(h?gj 2>7:

    (

    `pbrdt`rbisb

    &cj(t`lbk>>‟(‟)

    s.puso,t`lbk-bisb

    cj(t`lbk>>‟))&

    wocib,,!/s.p`p,--I/2,2-p`st!LB/!'

    )bisb&  !"c#b('s$bpt() && prbhbgbkhb(t`lbk) 9>

    prbhbgbkhb(s$t`p%;gdtd)) &&  &  !/s.p`p,-'

    p`st!LB/!'  )  s.puso,t`lbk-'

    )

     L

    7 4 9 ; 0 J F O E

    d a

    da(h gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    20/40

    da(h?gj 2>7:

    (

    cj,csdikun,t`lbk--

    `pbrdkg&

    p`st!LB/t`lbk' L'

    )

     L

    7 4 9 ; 0 J F O Ed a h

    da(h gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    21/40

    da(h?gj 2>7:

    `pbrdt`rbisb

    &cj(t`lbk>>‟(‟)

    s.puso,t`lbk-bisb

    cj(t`lbk>>‟))&

    wocib,,!/s.p`p,--I/2,2-p`st!LB/!'

    )bisb&  !"c#b(prbhbgbkhb(t`lbk) 9> prbhbgbkhb(s$t`p%;gdtd))

    && 's$bpt())  &  !/s.p`p,-'

    p`st!LB/!'  )  s.puso,t`lbk-'

    )

     L

    7 4 9 ; 0 J F O E

    d a h (

    da(h gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    22/40

    da(h?gj 2>7

     L

    7 4 9 ; 0 J F O E

    d a h ( g

    cj,csdikun,t`lbk-- `pbrdkg&

    p`st!LB/t`lbk' L')

    da(h gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    23/40

    da(h?gj >7

    `pbrdt`rbisb

    &cj(t`lbk>>‟(‟)

    s.puso,t`lbk-bisb

    cj(t`lbk>>‟))&

    wocib,,!/s.p`p,--I/2,2-p`st!LB/!'

    )bisb&  !"c#b(prbhbgbkhb(t`lbk) 9> prbhbgbkhb(s$t`p%

    ;gdtd)) && 's$bpt())  &  !/s.p`p,-'

    p`st!LB/!'  )  s.puso,t`lbk-'

    )

     L

    7 4 9 ; 0 J F O E

    d a h ( g

    da(h gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    24/40

    da(h?gj >7

    cj,csdikun,t`lbk-- `pbrdkg&p`st!LB/t`lbk'

     L')

     

     L

    7 4 9 ; 0 J F O E

    d a h ( g j  

    da(h gj 2>7:

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    25/40

    da(h?gj >7

    7

    ,a g-(, g -j

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    26/40

    d,a?g-(,h?gb-j 

    *`stx+>d

    %pbrdkg / d dgg t` p`st!b!prbssc`k

    8 `pbrdt`r puso ckt` stdhl

    , 8 dag

    ,

    ?

    ,

    *`stx+>dag%

    ,a g-(, g -j

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    27/40

    d,a?g-(,h?gb-j 

    *`stx+>d

    ag%

    (

    ,

    (

    *`stx+>dag%h

    ?

    ,

    (

    *`stx+>dag%hg

    ?

    ,

    (

    *`stx+>dag%

    hgb

    ?

    ,

    (

    *`stx+>dag%hgb,%-

    ,

    (

    (

    *`stx+>dag%hgb,%-.

    d,a g-(,h gb-j

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    28/40

    d,a?g-(,h?gb-j 

    *`stx+>dag%hgb,%

    -.j 

    *`stx+>dag%hgb,%-.j.

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    29/40

    1vdiudtc`k `j p`st!b!prbssc`k

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    30/40

    "hdk p`st! b!prbssc`k jr`n ibjt t`rcfot

    Cj `pbrdkg tobk puso ckt` stdhl

    1isb `pbrdt`r•

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    31/40

    j`r,c/7'p`st!cBI/2>7:'c-=

    t`lbk>p`stx4c1<

    cj(csd#p"d(t`lbk))

    =h`utMM1ktbr tob vdiub `j

    @MMt`lbkMM@/@'  hck33vdi4'

    s$pus"(8d#7)<2

    b#sb=

    ,,`pbrdt`r2

    2

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7

    D/;

    5/9*/0G/4$/J

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    32/40

    9

    j`r,c/7'p`st!cBI/2>7:'c-=

    t`lbk>p`stx4c1<

    cj(csd#p"d(t`lbk))

    =h`utMM1ktbr tob vdiub `j

    @MMt`lbkMM@/@'  hck33vdi4'

    s$pus"(8d#7)<

    2

    b#sb=

    ,,`pbrdt`r

    22

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7

    D/;

    5/9*/0G/4$/J

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    33/40

    0

    9;

    j`r,c/7'p`st!cBI/2>7:'c-=

    t`lbk>p`stx4c1<

    cj(csd#p"d(t`lbk))

    =h`utMM1ktbr tob vdiub `j

    @MMt`lbkMM@/@'  hck33vdi4'

    s$pus"(8d#7)<2

    b#sb=

    ,,`pbrdt`r

    22

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7

    D/;5/9*/0G/4$/J

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    34/40

    ;

    1isb&h"dr `p7: `p6<ckt 8d#7: 8d#6<`p9/s.p`p,-'`p4/s.p`p,-'

    vdi/bvdiudtb,`p4]`p9]t`lbk-'s.puso,vdi-'

    )

    *`p t!` `pbrdkg

    ?p6 > 3?p7 > 6

    5d# > 6-3 >

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7D/;5/9*/0G/4

    $/J

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    35/40

    44

    1isb&h"dr `p7: `p6<ckt 8d#7: 8d#6<`p9/s.p`p,-'`p4/s.p`p,-'

    vdi/bvdiudtb,`p4]`p9]t`lbk-'s.puso,vdi-'

    )

    *`p t!` `pbrdkg

    ?p6 > ?p7 >

    5d# > . >77

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7D/;5/9*/0G/4

    $/J

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    36/40

    4

    44

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7D/;5/9*/0G/4

    $/J

    cj(csd#p"d(t`lbk))=

    h`utMM1ktbr tob vdiub `j

    @MMt`lbkMM@/@'  hck33vdi4'

    s$pus"(8d#7)<2

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    37/40

    J4

    44

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7D/;5/9*/0G/4

    $/J

    cj(csd#p"d(t`lbk))=

    h`utMM1ktbr tob vdiub `j

    @MMt`lbkMM@/@'  hck33vdi4'

    s$pus"(8d#7)<2

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    38/40

    7

    44

    1isb&h"dr `p7: `p6<ckt 8d#7: 8d#6<`p9/s.p`p,-'`p4/s.p`p,-'

    vdi/bvdiudtb,`p4]`p9]t`lbk-'s.puso,vdi-'

    )

    *`p t!` `pbrdkg

    ?p6 > ?p7 > 7

    5d# > 7, >

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7D/;5/9*/0G/4

    $/J

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    39/40

    44

    1isb&h"dr `p7: `p6<ckt 8d#7: 8d#6<`p9/s.p`p,-'`p4/s.p`p,-'

    vdi/bvdiudtb,`p4]`p9]t`lbk-'s.puso,vdi-'

    )

    *`p t!` `pbrdkg

    ?p6 > ?p7 > 77

    5d# > 77% >77

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7D/;5/9*/0G/4

    $/J

  • 8/18/2019 Infix to Postfix and Evalaution of postfix

    40/40

    5d#>s$p`p()<

    ,,5d#>77

    7 4 9 ; 0 J F O E

    d a h ( g j ? >7D/;5/9*/0G/4

    $/J