[Dev-C++] Printing of an expression tree
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Noorez K. <lor...@ho...> - 2007-02-23 05:21:28
|
I'm having a bit of trouble with an assignment I need to do for recursion a=
nd binary trees. I need to print an arithmetic expression tree. The struct =
must be defined as follows:
=20
struct TreeNode{ char op; int number; TreePtr left; TreePtr right;};
=20
=20
void in_order_print(TreePtr tree){ TreePtr currentNode =3D tree;
if(currentNode !=3D NULL) { if(currentNode->left !=3D NULL) { =
in_order_print(currentNode->left); }
// print which data?
if(currentNode->right !=3D NULL) { in_order_print(currentNode->=
right); } }}
=20
Since there are two fields which contain data, how would I know in the recu=
rsive algorithm which one to print?
_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=3D7+wonders+world&mkt=3Den-US&form=3DQ=
BRE=
|