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

Speed of memory versus speed of CPU, In the past there was a large gap betw...

In the past there was a large gap between speed of a memory andprocessor. So a subroutine execution for an instruction for illustration floating point addition may have to follow a

Incorporating javascript into a web page, As we already know, HTML (Hyperte...

As we already know, HTML (Hypertext Markup Language) is the language we use to create Web documents. Now we will read "Hello World!" As given below:

Define compilers with high level programming language, Define Compilers wit...

Define Compilers with High Level Programming Language? All high-level programming language (except strictly interpretive languages) comes with a compiler. Effectively the compi

For which class address 192.5.48.3 belogs, Address 192.5.48.3 belongs to? ...

Address 192.5.48.3 belongs to? Address 192.5.48.3 belongs to class C.

Benefits of expert system to the user, a. It improves quality by providing ...

a. It improves quality by providing consistent advice and by making reduction in the error rate. b. Expert systems are reliable and they do not overlook relevant info

Explain the concept of switching, Question: (a) A computer network can...

Question: (a) A computer network can be a LAN or a WAN. Using appropriate diagrams and examples, explain what you understand by the term LAN. Your answer should also explain

How to make a datapool, When producing a datapool, you state the kinds of d...

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

Select statements linked to a logical database, One cannot use SELECT state...

One cannot use SELECT statements in a report program linked to a Logical Database   False. You can use th SELECT statements.

What is a file, What is a file? A file is a named collection of relate...

What is a file? A file is a named collection of related information that is recorded on secondary storage. A file having either programs or data. A file has sure "structure" b

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