Package com.zybooks.dsaj.tree
Class TraversalExamples
java.lang.Object
com.zybooks.dsaj.tree.TraversalExamples
Several applications of tree traversals.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intReturns 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> voidparenthesize(Tree<E> T, Position<E> p) Prints parenthesized representation of subtree of T rooted at p.static <E> voidprintPreorder(AbstractTree<E> T) static <E> voidprintPreorderIndent(Tree<E> T, Position<E> p, int d) Prints preorder representation of subtree of T rooted at p having depth d.static <E> voidstatic <E> voidprintPreorderLabeled(Tree<E> T, Position<E> p, ArrayList<Integer> path) Prints labeled representation of subtree of T rooted at p having depth d.static Stringspaces(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.
-