I am currently attempting to write a single recursive method (per instruction) whereas the items in a binary tree are displayed in a horizontal hierarchical manner (level order traversal).
The UML describes the method as:
levelOrderTraversal(TreeNode<T> tree, Integer indent)
- tree: a node in the binary tree
- indent: describes the indentation required for the node
The following is a example of the output that should be produced when levelOrderTraversal is called:
199 77 64 62 60 40 38 22 11
As mentioned, the instructions require that the method strictly use recursion (and thus implicitly am not allowed to use an iterative method using a queue/stack data structure). I've searched textbooks and Google, but I am honestly stumped. Any advice on how I can create this method would be truly appreciated.
Edited 5 Years Ago by jonpadre: Typo