![]() |
AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
|
example: transform recursive preoder traversal to iterative algorithm More...
Static Public Member Functions | |
| static void | recursive_traversal (BinaryTree< String > node, int level) |
| recursive algorithm More... | |
| static void | iterative_traversal (BinaryTree< String > root) |
| iterative algorithm More... | |
| static void | level_order_traversal (BinaryTree< String > root) |
| implement level-order traversal More... | |
| static BinaryTree< String > | exampleTree () |
| generate some tree More... | |
| static void | indent (int n) |
indent output on System.err More... | |
| static void | main (String[] args) |
example: transform recursive preoder traversal to iterative algorithm
We use VerboseStack to show that recursive_traversal and iterative_traversal effectively do the same.
In addition, a level_order_traversal is obtained by replacing the stack by a VerboseQueue.
Definition at line 17 of file IterativePreorderTraversal.java.
|
static |
generate some tree
Definition at line 67 of file IterativePreorderTraversal.java.
Referenced by aud.example.IterativePreorderTraversal.main().
Here is the caller graph for this function:
|
static |
indent output on System.err
Definition at line 89 of file IterativePreorderTraversal.java.
Referenced by aud.example.IterativePreorderTraversal.recursive_traversal().
Here is the caller graph for this function:
|
static |
iterative algorithm
Definition at line 34 of file IterativePreorderTraversal.java.
References aud.BinaryTree< T >.getLeft(), aud.BinaryTree< T >.getRight(), aud.Stack< T >.is_empty(), aud.example.VerboseStack< T >.pop(), and aud.example.VerboseStack< T >.push().
Referenced by aud.example.IterativePreorderTraversal.main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
implement level-order traversal
Definition at line 50 of file IterativePreorderTraversal.java.
References aud.example.VerboseQueue< T >.dequeue(), aud.example.VerboseQueue< T >.enqueue(), aud.BinaryTree< T >.getLeft(), aud.BinaryTree< T >.getRight(), and aud.Queue< T >.is_empty().
Referenced by aud.example.IterativePreorderTraversal.main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 94 of file IterativePreorderTraversal.java.
References aud.example.IterativePreorderTraversal.exampleTree(), aud.example.IterativePreorderTraversal.iterative_traversal(), aud.example.IterativePreorderTraversal.level_order_traversal(), and aud.example.IterativePreorderTraversal.recursive_traversal().
Here is the call graph for this function:
|
static |
recursive algorithm
Definition at line 21 of file IterativePreorderTraversal.java.
References aud.BinaryTree< T >.getLeft(), aud.BinaryTree< T >.getRight(), aud.example.IterativePreorderTraversal.indent(), and aud.example.IterativePreorderTraversal.recursive_traversal().
Referenced by aud.example.IterativePreorderTraversal.main(), and aud.example.IterativePreorderTraversal.recursive_traversal().
Here is the call graph for this function:
Here is the caller graph for this function: