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
Draw an expression tree for the string. f + (x+y) *((a+b)/(c-d)). Indicate the register requirement for each node and list out the evaluation order for the expression tree. For

What is meant by inferring latches, how to avoid it? Consider the following: always @(s1 or s0 or i0 or i1 or i2 or i3) case ({s1, s0}) 2'd0: out = i0; 2'd1: out =

What is the last entry in all BDC tables? In all BDC tables the last entry is to save the data by using the field name BDC_OKCODE and a field value of '/11'.

Reprographic Methods i) Thermography ii) Dyeline jii) Microfiche iv) Fax In this unit you have learnt that: Used for Methods of reprography are used for the

The conflict between too hot and too cold or too slow and too fast can be resolved using don't care states. Don't care states are used when i) the state of the output is not

Structuring the Web site is first step towards building the corporate Web site. Structuring includes creating a folder that includes all our picture files, text files and database

In a logical system, a judgement is a statement that is either true or false. So far, you are most familiar with the type of judgement "A is true", which is often simply abbreviate

Clustering has been existing since the 1980s when it was used in DEC's VMS systems. IBM's SYSLEX is a cluster approach for a mainframe system. Sun Microsystems, Microsoft, and othe

Yet another type of input is HIDDEN input. A HIDDEN input is a value/name pair which is returned to you but doesn

Q. Illustrate working of J-K flip-flop? J-K flip-flop is also a modification of SR flip-flop since it has 2 inputs same as S and R and all possible inputs combinations are vali