I need to show the "path" of the different nodes from a binary tree of strings. The function received two node (begin and end), assuming that they exist in the tree. The tree isn't ordered and cannot be ordered. I've thougt by using the preorder strategy.
For example if the input is monday and month the result should be:
monday party of month
Using the preorder the result is
monday party of friday month
Does anyone know to print the right path?
family
/ \
day monday
/ \ / \
zoo night party brother
/ \ / \ / \ / \
lion of at club
/ \
friday month
public void fa(NodeArbre inicial,NodeArbre fi){
if(inicial!=null){
System.out.println(inicial._contingut+ " _ ");
fa(inicial._esq,fi);
fa(inicial._dret,fi);
}
}