java.lang.Object | +--Searches
Trying out various tree searches.
| Constructor Summary | |
Searches()
|
|
| Method Summary | |
(package private) static boolean |
bfs(Tree root)
Performs a breadth-first search, starting from the given node, for any node that satisfies the condition isGoal(node). |
(package private) static Tree |
createTree()
Creates and returns a tree for use in testing the other methods. |
(package private) static boolean |
dfs(Tree root)
Performs a depth-first search, starting from the given node, for any node that satisfies the condition isGoal(node). |
(package private) static void |
dump(java.util.Stack stack)
Prints the contents of the stack (top to the left). |
(package private) static boolean |
isGoal(Tree node)
Defines a couple of nodes in the tree to be goal nodes. |
static void |
main(java.lang.String[] args)
|
(package private) static void |
postorderPrint(Tree node)
Traverses the given tree in postorder, printing node values on a single line. |
(package private) static void |
postorderPrint(Tree node,
java.lang.String indent)
Traverses the given tree in postorder, printing node values indented and on multiple lines. |
(package private) static void |
preorderPrint(Tree node)
Traverses the given tree in preorder, printing node values on a single line. |
(package private) static void |
preorderPrint(Tree node,
java.lang.String indent)
Traverses the given tree in preorder, printing node values indented and on multiple lines. |
(package private) static boolean |
recursiveDfs(Tree node)
Performs a depth-first search, starting from the given node, for any node that satisfies the condition isGoal(node), and prints the path from the goal back to the root. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Searches()
| Method Detail |
static boolean bfs(Tree root)
root - The root of the tree or subtree to be searched.
static Tree createTree()
static boolean dfs(Tree root)
root - The root of the tree or subtree to be searched.
static void dump(java.util.Stack stack)
static boolean isGoal(Tree node)
public static void main(java.lang.String[] args)
static void postorderPrint(Tree node)
static void postorderPrint(Tree node,
java.lang.String indent)
static void preorderPrint(Tree node)
static void preorderPrint(Tree node,
java.lang.String indent)
static boolean recursiveDfs(Tree node)