This is not the document you are looking for? Use the search form below to find more!

Report home > Computer / Internet

asdf

0.00 (0 votes)
Document Description
sadf
File Details
Submitter
  • Name: asdf
Embed Code:

Add New Comment




Related Documents

asdf

by: austin, 9 pages

asdf asdf

asdf

by: asdasdf, 1 pages

asdf

asdf

by: asdf, 5 pages

asdf

asdf

by: asdf, 2 pages

asdf

asdf

by: asdf, 3 pages

asdf

asdf

by: asdf, 1 pages

asfafs asdf asdfasdf

asdf

by: asf, 4 pages

asdf

asdf

by: asdf, 200 pages

asdf

asdf

by: asdf, 2 pages

asdf

asdf

by: asdf, 76 pages

asdf

Content Preview
ExpressionsTrees
Compilersneedtogeneratemachinecodeinwhichoneoperandisexecutedatatime.All
expressionshavetobebrokendownunambiguouslyintoseparateoperationsandputintotheir
properorder.Toachievethis,compilersusepostfixnotation.However,humansuseinfixnotation
whichisambiguousunlessbracketsareused.



Leavescontainoperands(constantsorvariables).Innernodescontainoperators.
BuildinganExpressionTreefromaPostfixExpression
Postfixnotationallowsforthecreationofanexpressiontree,whichimposesanorderonthe
executionofoperations.
Algorithm
Scantheexpressionfromlefttoright.
Ifthesymbolisanoperand,createaonenodetreeforitandpushitontothestack.
Ifthesymbolisanoperator,poptwotreesT1andT2.
MergeT1andT2,usingthesymbolastherootnodeandmakingthefirsttreepoppedtherightchild
andthesecondtheleftchild
Pushthenewlymergedtreeontothestack.
Example
Buildatreefromtheexpressionab+cde+**

2.ab+cde+**
1.ab+cde+**
3.ab+cde+**

4.ab+cde+**
5.ab+cde+**
6.ab+cde+**DONE!

Assignment
1.Givenapostfixexpression,buildatreeforit
2.Verifythecorrectnessofthetreebyoutputtingthepostfixexpressionusedtobuildit.
3.Outputtheinfixexpressionrepresentedbythetree,buteliminateambiguities.


Download
asdf

 

 

Your download will begin in a moment.
If it doesn't, click here to try again.

Share asdf to:

Insert your wordpress URL:

example:

http://myblog.wordpress.com/
or
http://myblog.com/

Share asdf as:

From:

To:

Share asdf.

Enter two words as shown below. If you cannot read the words, click the refresh icon.

loading

Share asdf as:

Copy html code above and paste to your web page.

loading
Advertisement