Package com.zybooks.dsaj.tree
Class TraversalExamples
java.lang.Object
com.zybooks.dsaj.tree.TraversalExamples
Several applications of tree traversals.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Returns total disk space for subtree of T rooted at p.static <E extends TraversalExamples.Geometric>
intlayout
(BinaryTree<E> T, Position<E> p, int d, int x) Defines geometry for an inorder layout of subtree of a binary tree.static <E> void
parenthesize
(Tree<E> T, Position<E> p) Prints parenthesized representation of subtree of T rooted at p.static <E> void
printPreorder
(AbstractTree<E> T) static <E> void
printPreorderIndent
(Tree<E> T, Position<E> p, int d) Prints preorder representation of subtree of T rooted at p having depth d.static <E> void
static <E> void
printPreorderLabeled
(Tree<E> T, Position<E> p, ArrayList<Integer> path) Prints labeled representation of subtree of T rooted at p having depth d.static String
spaces
(int n) Returns a string containing n spaces.
-
Constructor Details
-
TraversalExamples
public TraversalExamples()
-
-
Method Details
-
spaces
Returns a string containing n spaces. -
printPreorder
-
printPreorderIndentSlow
-
printPreorderIndent
Prints preorder representation of subtree of T rooted at p having depth d. -
printPreorderLabeled
Prints labeled representation of subtree of T rooted at p having depth d. -
parenthesize
Prints parenthesized representation of subtree of T rooted at p. -
diskSpace
Returns total disk space for subtree of T rooted at p. -
layout
public static <E extends TraversalExamples.Geometric> int layout(BinaryTree<E> T, Position<E> p, int d, int x) Defines geometry for an inorder layout of subtree of a binary tree.
-