Jump to content

Talk:Binary expression tree

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by PratikNadagouda (talk | contribs) at 18:13, 14 September 2011. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconComputer science Start‑class Low‑importance
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
LowThis article has been rated as Low-importance on the project's importance scale.
Things you can help WikiProject Computer science with:


Example

The input is: a b + c d e + * *


Since the first two symbols are operands, one-node trees are created and pointers are pushed to them onto a stack. For convenience the stack will grow from left to right.


The next symbol is a '+'. It pops the two pointers to the trees, a new tree is formed, and a pointer to it is pushed onto to the stack.


Next, c, d, and e are read. A one-node tree is created for each and a pointer to the corresponding tree is pushed onto the stack.


Continuing, a '+' is read, and it merges the last two trees.


Now, a '*' is read. The last two tree pointers are popped and a new tree is formed with a '*' as the root.


Finally, the last symbol is read. The two trees are merged and a pointer to the final tree remains on the stack.[1] PratikNadagouda (talk) 18:10, 14 September 2011 (UTC)[reply]

  1. ^ Cite error: The named reference Gopal2010 was invoked but never defined (see the help page).