Write a recursive algorithm, Computer Engineering

Assignment Help:

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.


Related Discussions:- Write a recursive algorithm

Explain lan topologies, Explain LAN Topologies and its basic topologies. ...

Explain LAN Topologies and its basic topologies. LAN Topologies: Network topology is a physical schematic that shows interconnection of the various users. There are four fund

What is edi (electronic data interchange), What is EDI (Electronic Data Int...

What is EDI (Electronic Data Interchange)? EDI: Electronic Data Interchange (EDI) is used by organizations for transactions that happen on regular basis to a pre-determined for

And-elimination-introduction rule - artificial intelligence, And-Eliminatio...

And-Elimination-Introduction rule - Artificial intelligence: And-Elimination In English, this says that "if you know that many things are all true, then you know that any

Automated reasoning - first-order logic, Automated Reasoning - first-order ...

Automated Reasoning - first-order logic: The topic known as "Automated Reasoning" in "AI"concentrates mostly on deductive reasoning, here new facts are logically deduced from

What is dvd and dvd-rom, DVD is a new technology very same to compact discs...

DVD is a new technology very same to compact discs. A DVD looks just like an ordinary compact disc, though a DVD can hold up to 25 times as much as a CD!! That's 18 gigabytes!! Thi

Can you define a field without a data element, Can you define a field witho...

Can you define a field without a data element? Yes.  If you require specifying no data element and thus no domain for a field, you can enter data type and field length and a sh

Determine the equivalent binary form of decimal number, Solve the equation ...

Solve the equation 23.6 10 = X 2 for X Ans. 23.6 10 = X 2 So as to find X, firstly convert the Decimal number 23.610 in its Binary form. After that take the decimal inte

Why wap gateways are used, Why WAP gateways are used? The Wireless Appl...

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

C program, find area uder the curve y=f(x) between x=a and x=b Posted Date...

find area uder the curve y=f(x) between x=a and x=b Posted Date: 9/1/2012 1:50:09 AM

What is the session, What is the session.  Session is a collection of v...

What is the session.  Session is a collection of various groups of method. Every session is assigned to a single control terminal. This terminal is either a pseudo-device. or a

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd