#include <iostream>
usingnamespace std;
struct Tree{
int data;
Tree* Right;
Tree* Left;
};
int main(){
Tree* Root = NULL;
Tree* RightBranch = NULL;
Tree* LeftBranch = NULL;
Tree* Current = NULL;
Root = new Tree;
RightBranch = new Tree;
LeftBranch = new Tree;
Current = new Tree;
Root->data = 1;
Root->Left = LeftBranch;
Root->Right = RightBranch;
RightBranch->data = 3;
RightBranch->Left = NULL;
RightBranch->Right = NULL;
LeftBranch->data = 2;
LeftBranch->Left = NULL;
LeftBranch->Right = NULL;
Current = Root;
while(Current != NULL){
cout << Current->data << endl;
Current = Current->Left;
}
system("PAUSE");
}
Hello everyone :), so been looking online for a way to print binary trees, and every site ive been to has been way to complex for my current level :) so I was hoping that you very smart guys and gals would be able to assist me!
I have it setup to print the left side of the tree but I can't figure out how to print both the right and left :(, and I would love for someone to push me in the right direction that way I learn faster :).