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
When producing a datapool, you state the kinds of data (called data types) that the script will send for example, customer names, addresses, and unique order numbers or product nam

Explain Client Server Model. In the client- server model, communication usually takes the form of a request message from the client to the server asking for several works to be

This assignment is based around two UK websites. In order to avoid difficulties such as the websites changing, or disappearing, we have downloaded these websites and you can find t

Question: a Describe the following terms with reference to video editing: 1. Video frame rate 2. Pixel aspect ratio 3. Frame size 4. Temporal compression 5. Spatial comp

Distinguish between ROM, PROM, EPROM, EEPROM. Ans: ROM: It also called Read Only Memory is a Permanent Memory. The data is permanently stored and cannot be changed in Perm

What are the restrictions on Subscreens? Subscreens have various restrictions.  They cannot: Set their own GUI status Have a named OK code Call another screen

Q. How can we minimize problems occurring because of the branch instructions? We may use various mechanisms which may minimize the effect of branch penalty. To keep mult

Computer Memories Computer memories are either external or internal. Internal memories are either RAM (random access memory) or ROM (read only memory). External memories can t

Explain the term - Integrity In most cases, corporate data should remain unchanged by third parties, so the system should be capable of ensuring that only authorised personn

Artificial Neural Networks: However imagine now in this example as the inputs to our function were arrays of pixels and there actually taken from photographs of vehicles such