ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

c++

by | Nov 30, 2023 | questions

hi there i need itcorrectly –
159.201 Algorithms & Data Structures semester 1 -2013 Assignment 5 Write a C++ program that creates and populate a tree for an arithmetic expression. Then it should perform an in-order and a post-or

Document Preview:

159.201 Algorithms & Data Structures semester 1 -2013 Assignment 5 Write a C++ program that creates and populate a tree for an arithmetic expression. Then it should perform an in-order and a post-order traversal on the tree. The input of the program will be a text file with the arithmetic expressions in RPN. The output of the program will be a printout of the arithmetic expression written out in both in-fix and post-fix (Reverse Polish) notations. The program does not need to compute the value of the expressions, only print them out. Note: -The in-fix notation must have all brackets in the right places i.e. the in-order traversal must be modified to achieve this. -The post-fix print out is useful for debugging purposes, as it should look like the original text file. -You need to use a stack that is able to store Tree pointers. You can modify the Stack we developed in class, or use STL. Remember that you can use the following algorithm to build the tree out of a file with the post-fix notation: An algorithm to construct an arithmetic tree Read in an expression that is already in post-fix notation. Tree *T1, *T2, *T; Stack S; //note that S is a stack of pointers to trees while (expression continues) { x = next item from the expression if (x is a number) { S.Push(new Tree(x, NULL, NULL)); } if (x is an operator) { T1 = S.Top(); S.Pop(); T2 = S.Top(); S.Pop(); S.Push(new Tree(x, T2, T1)); //note order of T2 and T1 } } T = S.Top(); Submit a one file code on Stream by 6pm on Wednesday 2 of May 2013. Your name and ID number must appear on top of the file as comments. If you are working in a group then all names and IDs must appear on top of the file as comments. Submit one file per group on Stream.

Attachments:


ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!