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
Artificial intelligence language processing (AILP) is a field of computer science and linguistics concerned with the interactions among computers and human (natural) languages; it

Connectives in first-order logic sentences - Artificial intelligence We may string predicates together into a sentence in the same way by utilising connectives that we did for

Determine the uses of Smart cards  These comprise embedded microchips and receive power from the card readers; Microchip is made up of RAM, ROM and 16-bit processor and the st

Allocation of Bits among Opcode and Operand The trade-off here is between numbers of bits of opcode vs. the addressing capabilities. An interesting development in this regard i

Determine the BIOS function with one illustration BIOS stands for Basic Input Output System. It is a set of programs to provide most basic low-level services like services keyb

What is cyclomatic complexity? Cyclomatic complexity is a computer science metric (measurement) developed by Thomas McCabe used to generally calculate the complexity of a progr

What is assembly language? A complete set of symbolic names and rules for the use of machines comprise a programming language, usually referred to as an assembly language.

XCF is GIMP's "native" format. This will preserve all information about an image, having the layers.

Why IO devices cannot be directly be connected to the system bus? The IO devices cannot be directly linked to the system bus because i.  The data transfer rate of IO device

(1-x^2 ) (d^2 y)/?dx?^(2 ) -x dy/dx-4y=0