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
Network throughput It is an indicative measure of the point carrying capacity of a network. It is distinct as the total number of messages the network can transmit per unit tim

Explain the characteristics of vector processing

Virtual Manufacturing System Virtual manufacturing system or VMS is a synthetic, integrated manufacturing environment, developed by using information technology tools, exercise

What are the address-sequencing capabilities required in a control memory? i. Incrementing the control address register ii. Unconditional branch as specified by address fiel

Q. Explain about Barrier? Barrier: No actual transfer of data takes place in this mode unless all the processors involved in the communication execute a particular block, calle

State the hardware faults and softwate faults - protection against hardware faults could be to keep backups or use GFS; use of UPS (in case of power loss) and parallel system a

Determine about the security- accidental damage accidental damage is best guarded against by keeping back up files or use Grandfather-Father-Son (GFS) method; also use of passw

Why WAP gateways are used? The Wireless Application Protocol Gateway is a very unique product giving semi -automatic redirection of HTML documents to WAP compatible mobile phon

Differences between internal and external treatment in boiler

how can we find compound interest through flowchart