Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 *node,int& pos)

{

}

//recursive function that prints the tree in Postfix equivalent

template

void Postfix(BinaryNode* node)

{

}

Part b:

Write the following recursive functions,

Function that takes an expression and makes the tree

void MakeTree(string expr, BinaryNode *node,int& pos)

Function that prints the tree in Postfix equivalent

template

void Postfix(BinaryNode* node)

{

}

Function that prints the tree in Infix equivalent

template

void Infix(BinaryNode* node)

{

}

Test with the below given main which should produce the output:

BinaryNode* root = new BinaryNode(' ');

int pos = 0;

cout

MakeTree("((a+(b*c))+(((d*e)+f)*g))", root,pos);

cout

Postfix(root);

cout

Infix(root);

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago