JavaAlgorithms
Elementary and no so elementary Java algorithms
treeAlgorithms.Algorithms Class Reference

List of all members.

Classes

interface  NodeVisitor< T extends Comparable< T > >

Static Public Member Functions

static< TextendsComparable< T >
boolean 
isOrdered (TreeNode< T > root)
static< TextendsComparable< T >
void 
inOrder (TreeNode< T > root, NodeVisitor< T > visitor)

Detailed Description

Algorithms Jun 20, 2013

Author:
Ian Kaplan, iank@bearcave.com

Definition at line 16 of file Algorithms.java.


Member Function Documentation

static <TextendsComparable<T> void treeAlgorithms.Algorithms.inOrder ( TreeNode< T >  root,
NodeVisitor< T >  visitor 
) [static]

In-order tree traversal. For an ordered tree, this will visit the nodes in increasing order.

Parameters:
rootthe current root of the tree
visitora class that implements NodeVisitor that performs an operation when the tree node is visited.
visitan object that implements the visit() method to so something when the node is visited.

Definition at line 97 of file Algorithms.java.

static <TextendsComparable<T> boolean treeAlgorithms.Algorithms.isOrdered ( TreeNode< T >  root) [static]

A function that tests whether a tree is ordered or not. One can imagine a use for such a function. This is an interview question during a very unpleasant interview at Sumo Logic.

Parameters:
rootthe root of a binary tree
Returns:
true if the tree is ordered (where the left branch is the less than branch and the right branch is the greater than branch), false otherwise.

Definition at line 47 of file Algorithms.java.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables