Write a recursive algorithm, Computer Engineering

Write a recursive algorithm to count the number of right children in a binary search tree.

Write the method levelCount whose header is given below. Method levelCount returns the number of nodes on the specified level.

int BinarySearchTree :: levelCount(BinaryNode* t, int level);

1770_Write a recursive algorithm.png

For this problem, the root is at level zero, the root's children are at level one, and for any node N its level is one more than N's parent's level. For example, for the bean-tree diagrammed below, the call levelCount(t,1) should return 2 (chickpea and navy are on level 1); the call levelCount(t,2) should return 3; and the call levelCount(t,4) should return 0.

Hint: when the level is 0, there is always just one node at that level, the root node (assuming it isn't empty), so return 1. If the level isn't zero, recursive calls will be used to determine the number of nodes at the requested level, and the level-requested should change in the recursive calls.

Posted Date: 4/2/2013 1:27:27 AM | Location : United States







Related Discussions:- Write a recursive algorithm, Assignment Help, Ask Question on Write a recursive algorithm, Get Answer, Expert's Help, Write a recursive algorithm Discussions

Write discussion on Write a recursive algorithm
Your posts are moderated
Related Questions
The decimal equivalent of (1100) 2   is ? Ans. (1100) 2 = (12) 10

Learning Weights in Perceptrons: Furthermore details are we will look at the learning method for weights in multi-layer networks next lecture. Thus the following description o

Potential of Parallelism Problems in the actual world differ in respect of the amount of inherent parallelism intrinsic in respective problem domain. Some problems can be easil

Intentional hacking helps in maintaining better security Several companies employ professionals as security specialists whose basic job is to detect and cover loopholes in t

Explain the violating basic security principles There are drawbacks to permitting users to access the Intranet as well as not permitting them. A simple consideration such as a

What are the critical capabilities for superior firm performance in e-commerce? Three firm capabilities which are critical for superior firm performance within e-commerce are:

Requirement Specification for a Simple Application to Model a Garden The following is a requirements statement for a simple application to model the design of a garden. The requ

Cross Bar The crossbar network is the easiest interconnection network. It has a two dimensional grid of switches.  It is a non-blocking network and give connectivity among inp

Reset and Submit are special types of input buttons. Submit is used to send data to the server and Reset resets/clears the form.

DOM is the Document Object Model (DOM) which is an interface specification handled by the W3C DOM Workgroup that explains an application independent mechanism to access, parse, or