0
Help me fix my Binary Tree Traversal - Preorder, Inorder, Postorder
I am trying to get the following output Preorder: 50 5 20 15 27 42 35 25 55 70 60 80 95 90 75 Inorder: 5 15 20 25 27 35 42 50 55 60 70 75 80 90 95 Postorder: 5 20 15 27 42 35 25 55 70 60 80 95 90 75 50 Instead I am getting this Preorder: 136161285312597531284813109128551336214133138721362114128146401438414645 Inorder: 531259712848128531285513109133621361613621138721412814133143841464014645 Postorder: 531284812597128551336213109128531362114128138721438414645146401413313616 Here is my code https://code.sololearn.com/cnXTqRz7kXmQ
1 Antwort
0
You had two issues. Your insert wanted int data passed to it and you had characters ('50'). Your order cout statements needed to output space to separate the data. Here is my updated code:
https://code.sololearn.com/cUL0HkpXzH37/?ref=app