Starting from the next binary tree, I should print the words it may contain on the screen, with a line break between them.
I have obtained functions like going through all the nodes to add their content or simply count the nodes, but I do not understand how to print each word always starting with the main root (letter B) and reusing letters
Function number of nodes:
public static int numNodos(Arbol a) {
if (a.esVacio()) {
return 0;
} else {
return 1 + numNodos(a.hijoIzq) + numNodos(a.hijoDcho());
}
}
Tree depth function:
public static int profundidad(Arbol a, int maxprof) {
if (a.esVacio()) {
return maxprof;
} else {
return Math.Max(profundidad(a.hijoIzq(), maxprof + 1), profundidad(a.hijoDcho(), maxprof + 1));
}
}