Define a new class named BSTWithNumberOfNonLeaves that extends BST with the following methods: /** Return the number of nonleaf nodes */ public int getNumberofNonLeaves() // BEGIN REVEL SUBMISSION class BSTWithNumberOfNonLeaves extends BST { /** Create a default BST with a natural order comparator */ public BSTWithNumberOfNonLeaves() { super(); } /** Create a BST with a specified comparator */ public BSTWithNumberOfNonLeaves(java.util.Comparator c) { super(c); } /** Create a binary tree from an array of objects */ public BSTWithNumberOfNonLeaves(E[] objects) { super(objects); } public int getNumberOfNonLeaves() { return getNumberOfNonLeaves(root); } /** Returns the number of non-leaf nodes */ private int getNumberOfNonLeaves(TreeNode root) { // WRITE YOUR CODE HERE } } // END REVEL SUBMISSION

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 34SA
icon
Related questions
Question

(Find the nonleaves) Java

Define a new class named BSTWithNumberOfNonLeaves that extends BST with the following methods:

/** Return the number of nonleaf nodes */
public int getNumberofNonLeaves()

// BEGIN REVEL SUBMISSION class BSTWithNumberOfNonLeaves<E> extends BST<E> { /** Create a default BST with a natural order comparator */ public BSTWithNumberOfNonLeaves() { super(); } /** Create a BST with a specified comparator */ public BSTWithNumberOfNonLeaves(java.util.Comparator<E> c) { super(c); } /** Create a binary tree from an array of objects */ public BSTWithNumberOfNonLeaves(E[] objects) { super(objects); } public int getNumberOfNonLeaves() { return getNumberOfNonLeaves(root); } /** Returns the number of non-leaf nodes */ private int getNumberOfNonLeaves(TreeNode<E> root) { // WRITE YOUR CODE HERE } } // END REVEL SUBMISSION

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning