Hey again,
This time I'm completely lost. I know what the tree data structure is, how it works, etc., but I need to design a method that will sequentially print out all the paths in the tree (i.e. for each node).
The method as provided is
Now the
string that must be returned needs to be of the format:
root.getData() + " " + path + "\n"
root.getData()[1] + " " + path[1] + "\n"
etc.
The pseudocode I was thinking of doing was something along the lines of:
Problems:
(1) I don't know how to determine "path" before the left and right children check (the root node's path is "", the first left node's path is "0", the first right node's path is "1",
pattern continues with left being "0" and right being "1").
(2) I don't know where to put newlines precisely.
(3) I'm not sure how to get the print layout precisely as it is supposed to be. At most I've been able to just get the last number in the sequence (i.e. if it was supposed to be "1000", I could get "0".
Honestly I really just need help with the pseudocode formulation, especially in regards to the logic and formatting. I think once I have an understanding of what is going on, I can solve it. And yes, I've gone through a couple pseudocode rewrites (a few hours worth) and haven't gotten anywhere which is slightly unnerving. Thanks so much and please let me know ASAP if more info is needed!!