Question
USE BinaryNode structure as provided to: template struct BinaryNode { Object element; BinaryNode *left; BinaryNode *right; BinaryNode(const Object & theElement, BinaryNode *lt= nullptr, BinaryNode *rt=nullptr)
USE BinaryNode structure as provided to:
template
struct BinaryNode
{
Object element;
BinaryNode *left;
BinaryNode *right;
BinaryNode(const Object & theElement, BinaryNode *lt= nullptr, BinaryNode *rt=nullptr)
: element{ theElement }, left{ lt }, right{ rt } { }
};
//A recursive function that takes an expression and makes the tree
template
void MakeTree(string expr, BinaryNode
{
}
//recursive function that prints the tree in Postfix equivalent
template
void Postfix(BinaryNode
{
}
Part b:
Write the following recursive functions,
Function that takes an expression and makes the tree
void MakeTree(string expr, BinaryNode
Function that prints the tree in Postfix equivalent
template
void Postfix(BinaryNode
{
}
Function that prints the tree in Infix equivalent
template
void Infix(BinaryNode
{
}
Test with the below given main which should produce the output:
BinaryNode
int pos = 0;
cout
MakeTree("((a+(b*c))+(((d*e)+f)*g))", root,pos);
cout
Postfix(root);
cout
Infix(root);
PLEASE answer clearly with comments. Will provide a thumbs up if above rules followed and desired output is achieved :)
CAUsers pkolliNDesktop\Fall18 CMP305\FileSystem\DebugBinary.exe Expression-((a+(bc))+( ((de)+f) g)) Postfix equivalent: a bcdef+ g * + Infix equivalent: + a(bc)) Press any key to continue de)f)g) CAUsers pkolliNDesktop\Fall18 CMP305\FileSystem\DebugBinary.exe Expression-((a+(bc))+( ((de)+f) g)) Postfix equivalent: a bcdef+ g * + Infix equivalent: + a(bc)) Press any key to continue de)f)g)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started