Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Ternary trees

  Asked By: Abbie    Date: Jun 13    Category: Java    Views: 1358

How could go about programming the following methods?
I need to gain an understanding of the logic behind it so if anyone
can suggest an Algorithm for them that would be great.
All are for manipulate search trees of order 3.

int size_of_tree(TreeNode tree)
It counts the total number of nodes of the given tree and return the
number back.

int depth_of_tree(TreeNode tree)
It is returns the depth of the given tree.

TreeNode make_partial_copy(TreeNode tree)
It generates a partial copy of the given tree such that all leaves of
the tree are removed.

boolean search(TreeNode tree, String key)
It checks whether the input key is actually in the tree.