Introduction to Java Programming and Data Structures, Comprehensive Version, Student Value Edition (11th Edition)
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
What are the similarities and differences between massively parallel processing systems and grid computing. with references
Modular Program Structure. Analysis of Structured Programming Examples. Ways to Reduce Coupling. Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.
Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr