Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
Question
Book Icon
Chapter 25, Problem 25.7PE
Program Plan Intro

Program Plan:

Include the required packages. Define the class “Test”.

  • Define the driver method “main”.
    • Declare the object for the “BST” class.
    • Call the method “insert” to add string values to the tree.
    • Call the “getNumberOfNonLeaves” method and display the result.
  • Define the “BST” class.
    • Define the “getNumberOfNonLeaves” method.
      • Return the number of non-leaves node.
        • Define the overridden method “getNumberOfNonLeaves”.
          • If the “root” is “null”,
            • return “0”.
          • If the “root.left” or “root.right” is not “null”,
            • Return the number of non-leaves node.
          • Otherwise,
            • return “0”.
        • Declare the required variables.
        • Create a constructor for “BST” class.
        • Create a constructor for “BST” by passing array of objects.
        • Define the “search” method to search the required data in the binary search tree.
        • Define the “insert” method.
          • If the root is null create the tree otherwise insert the value into left or right subtree.
        • Define the “createNewNode”
          • Return the result of new node creations.
        • Define the “inorder”
          • Inorder traverse from the root.
        • Define the protected “inorder” method
          • Traverse the tree according to the inorder traversal concept.
        • Define the “postorder”
          • Postorder traverse from the root.
        • Define the protected “postorder” method
          • Traverse the tree according to the postorder traversal concept.
        • Define the “preorder”
          • Preorder traverse from the root.
        • Define the protected “preorder” method
          • Traverse the tree according to the preorder traversal concept.
        • Define the “TreeNode” class
          • Declare the required variables.
          • Define the constructor.
        • Define the “getSize” method.
          • Return the size.
        • Define the “getRoot” method
          • Return the root.
        • Define the “java.util.ArrayList” method.
          • Create an object for the array list.
          • If the “current” is not equal to null, add the value to the list.
          • If the “current” is less than 0, set the “current” as left subtree element otherwise set the “current” as right subtree element.
          • Return the list.
        • Define the “delete” method.
          • If the “current” is not equal to null, add the value to the list.
          • If the “current” is less than 0, delete the “current” as left subtree element otherwise delete the “current” as right subtree element.
          • Return the list.
        • Define the “iterator” method.
          • Call the “inorderIterator” and return the value.
        • Define the “inorderIterator”
          • Create an object for that method and return the value
        • Define the “inorderIterator” class.
          • Declare the variables.
          • Define the constructor.
            • Call the “inorder” method.
          • Define the “inorder” method.
            • Call the inner “inorder” method with the argument.
          • Define the TreeNode “inorder” method.
            • If the root value is null return the value, otherwise add the value into the list.
          • Define the “hasNext” method
            • If the “current” value is less than size of the list return true otherwise return false.
          • Define the “next” method
            • Return the list.
          • Define the “remove” method.
            • Call the delete method.
            • Clear the list then call the “inorder” method.
        • Define the “clear” method
          • Set the values to the variables
  • Define the interface.
    • Declare the required methods.
    • Define the required methods.

Blurred answer
Students have asked these similar questions
(TicTacToe Class) Create a class TicTacToe that will enable you to write a complete programto play the game of tic-tac-toe. The class contains as private data a 3-by-3 two-dimensional arrayof integers. The constructor should initialize the empty board to all zeros. Allow two human players.Wherever the first player moves, place a 1 in the specified square. Place a 2 wherever the second player moves. Each move must be to an empty square. After each move, determine whether the gamehas been won or is a draw. If you feel ambitious, modify your program so that the computer makesthe moves for one of the players. Also, allow the player to specify whether he or she wants to go firstor second. If you feel exceptionally ambitious, develop a program that will play three-dimensionaltic-tac-toe on a 4-by-4-by-4 board. [Caution: This is an extremely challenging project that couldtake many weeks of effort!]
Please help me with this , I am stuck ! PLEASE WRITE IT IN C++ Thanks 1) bagUnion:  The union of two bags is a new bag containing the combined contents of the original two bags. Design and specify a method union for the ArrayBag that returns as a new bag the union of the bag receiving the call to the method and the bag that is the method's parameter.  The method signature (which should appear in the .h file and be implemented in the .cpp file is:     ArrayBag<T> bagUnion(const ArrayBag<T> &otherBag) const; This method would be called in main() with:     ArrayBag<int> bag1u2 = bag1.bagUnion(bag2); Note that the union of two bags might contain duplicate items.  For example, if object x occurs five times in one bag and twice in another, the union of these bags contains x seven times. The union does not affect the contents of the original bags.   Here is the main  file: #include <cstdlib>#include <iostream>#include "ArrayBag.h"using namespace std; template…
(In Java language) Create a class Called NetflixDemo  Create two objects “user1” and “user2” of the Netflix class pictured below) Set various class variables for the Netflix class using these two objects. Call various methods of Netflix class using these two objects.   public class Netflix {public String movies [] = new String[10];public String trendingTop5 [] = new String[5];public String continueWatching [] = new String[5];public String username;public String password;private boolean isAuthenticated;public double balance;public int subscriberSinceYear;public static void logininfo() {Scanner input = new Scanner(System.in);System.out.println("Enter the username");String username = input.nextLine();System.out.println("Enter the password");String password = input.nextLine();boolean isAuthenticated = true;System.out.println(isAuthenticated + " , You have successfully logged in ");System.out.println();}public static void trendingList(){Scanner input = new…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education