
A method “countLeftNodes()”
Program plan:
- Define the method “countLeftNodes()”,
- Return the value returned from the parameterized method “countLeftNodes()”.
- Define the parameterized method “countLeftNodes()”,
- Check whether the root of the tree is null,
- If it is true, return “0”.
- Otherwise, check whether the left node of the tree is null,
- Return the value returned from the parameterized method “countLeftNodes()”.
- Otherwise, return the calculated value.
- Otherwise, check whether the left node of the tree is null,
- If it is true, return “0”.
- Check whether the root of the tree is null,

This program demonstrates the method “countLeftNodes()” that return the number of left children in the tree.
Explanation of Solution
Code:
//Define the method
public int countLeftNodes()
{
/*Return the value returned from the parameterized method "countLeftNodes()"*/
return countLeftNodes(overallRoot);
}
//Define the parameterized method method "countLeftNodes()"
private int countLeftNodes(IntTreeNode root1)
{
//Check whether the root is null
if (root1 == null)
{
//Return "0"
return 0;
}
/*Otherwise, check whether the left node of the tree is null*/
else if (root1.left == null)
{
/*Return the value returned from the parameterized method "countLeftNodes()"*/
return countLeftNodes(root1.right);
}
else
{
//Return the calculated value
return 1 + countLeftNodes(root1.left) + countLeftNodes(root1.right);
}
}
Want to see more full solutions like this?
Chapter 17 Solutions
Building Java Programs: A Back To Basics Approach (5th Edition)
- a) Show a possible trace of the OSPF algorithm for computing the routing table in Router 2 forthis network.b) Show the messages used by RIP to compute routing tables.arrow_forwardusing r language to answer question 4 Question 4: Obtain a 95% standard normal bootstrap confidence interval, a 95% basic bootstrap confidence interval, and a percentile confidence interval for the ρb12 in Question 3.arrow_forwardusing r language to answer question 4. Question 4: Obtain a 95% standard normal bootstrap confidence interval, a 95% basic bootstrap confidence interval, and a percentile confidence interval for the ρb12 in Question 3.arrow_forward
- The assignment here is to write an app using a database named CIT321 with a collection named students; we will provide a CSV file of the data. You need to use Vue.js to display 2 pages. You should know that this assignment is similar, all too similar in fact, to the cars4sale2 example in the lecture notes for Vue.js 2. You should study that program first. If you figure out cars4sale2, then program 6 will be extremely straightforward. It is not my intent do drop a ton of new material here in the last few days of class. The database contains 51 documents. The first rows of the CSV file look like this: sid last_name 1 Astaire first_name Humphrey CIT major hrs_attempted gpa_points 10 34 2 Bacall Katharine EET 40 128 3 Bergman Bette EET 42 97 4 Bogart Cary CIT 11 33 5 Brando James WEB 59 183 6 Cagney Marlon CIT 13 40 GPA is calculated as gpa_points divided by hrs_attempted. GPA points would have been arrived at by adding 4 points for each credit hour of A, 3 points for each credit hour of…arrow_forwardI need help to solve the following case, thank youarrow_forwardhi I would like to get help to resolve the following casearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





