龙书第二章答案snooz_1

龙书第二章答案snooz_1

ID:28279635

大小:100.54 KB

页数:7页

时间:2018-12-09

龙书第二章答案snooz_1_第1页
龙书第二章答案snooz_1_第2页
龙书第二章答案snooz_1_第3页
龙书第二章答案snooz_1_第4页
龙书第二章答案snooz_1_第5页
资源描述:

《龙书第二章答案snooz_1》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、CS431,Assignment3,BookQuestionsonChapter2PlusOneOtherQuestionQuestionsthatyouneedtoanswerarelistedbelow,andsomesolutionsorpartialsolutionsarealsogiven.Thesolutionsarenotpresentedastheonlypossibleanswers,andwhatisgivenmaynotbecomplete.Itmayonlybeastartingpointforthinkingab

2、outacomplete,correctanswer.Yourgoalinworkingtheproblemsshouldbetocomeupwithasolution,andifindoubtaboutyouranswer,comparewithwhat’sgivenhere.Intheory,evenifyouranswerisnotexactlythesame,youshouldseethesenseorunderstandthedirectionofthesuggestions.Ifyouranswerisatoddswithwh

3、atIhavesuggestedyoumightwanttocheckwithme.ItispossiblethatIamoffbase.Itisalsopossiblethatyouneedsomethingsclarified.Bookproblems:2.1,a-c;2.2,a-e;2.3;2.4,a-e,and2.8.Suggestedanswerstothesequestionsaregivenafterthefollowingquestion.Lastproblem:Thereisanadditionalproblemthat

4、isnotfromthebook.Itisstatedhere.ImplementJavacodethatwillcorrectlytranslateinfixexpressionswith+and–(noparenthesesandnootheroperators)topostfixexpressions.AproblemsolutionisgiveninthebookinCcode,soyourtaskismainlyoneofadaptation.AstartingpointforthisproblemispostedontheWe

5、bpage.YoumayusethefileInfixToPostfixCut.javaasgivenandsimplyaddtheneededmethods.Youcanalsodotheproblemfromscratchifyouwantto.Ithinkitwouldbepreferableifyouleftyourimplementationrecursiveratherthanchangingittoaloop,butthatisyourchoice.Handinaprintoutofthemethodsyouaddedalo

6、ngwithyouranswerstotheproblemslistedabove.Startingpointsforthinkingaboutsolutions:2.1.Considerthefollowingcontext-freegrammarSàSS+(1)SàSS*(2)Sàa(3)a)Showhowthestringaa+a*canbegeneratedbythisgrammar.Production(3)allowsyoutogenerateastringS0whichconsistsofa.UsingS0asastarti

7、ngpoint,production(1)allowsyoutogenerateastringS1whichconsistsofaa+.Production(3)againallowsyoutogenerateastringS2whichconsistsofa.Thenproduction(2)allowsyoutogenerateastringS3=S1S2*=aa+a*.b)Constructaparsetreeforthisstring.SSSSS*+aaac)Whatlanguageisgeneratedbythisgrammar

8、?Justifyyouranswer.Assumingaisanidentifierforanumericvalue,forexample,thenthegrammargeneratesala

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。