Kirby
Lifer
Tree
I have to write a binary tree that outputs the post-order traversal of the tree given the pre-order and in-order, and either my program is wrong (most likely) or me writing it out is wrong. I'm pretty sure I fouled up the recursion.
This is what I get on paper
Pre: f b a d c e h g j i k
InO: a b c d e f g h i j k
Pst: a c e d b g i k j h f
Correct?
However my output is: a c g i k j h e d b f
More interesting, if I use this set:
Pre: a c x Q F r t !
InO: c a x F Q t r !
Pst: c F t ! r Q x a
I get the correct post-order. 😕
I have to write a binary tree that outputs the post-order traversal of the tree given the pre-order and in-order, and either my program is wrong (most likely) or me writing it out is wrong. I'm pretty sure I fouled up the recursion.
This is what I get on paper
Pre: f b a d c e h g j i k
InO: a b c d e f g h i j k
Pst: a c e d b g i k j h f
Correct?
However my output is: a c g i k j h e d b f
More interesting, if I use this set:
Pre: a c x Q F r t !
InO: c a x F Q t r !
Pst: c F t ! r Q x a
I get the correct post-order. 😕