Introduction to Java Programming and Data Structures  Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134700144
Author: Liang
Publisher: PEARSON
Question
Book Icon
Chapter 25, Problem 25.17PE
Program Plan Intro

Program Plan:

  • Include the required import statement.
  • Define the main class.
    • Declare the necessary variables
    • Using start initialize the required.
      • Create border pane, tree view, text field and button.
      • Set the tree view as center, alignment.
      • Add an action event to the button.
      • Create a scene and place the pane in the stage.
      • Set the title.
      • Place the scene in the stage.
      • Display the stage.
    • Define the main method using public static main.
      • Initialize the call.
    • Define “decode” method.
      • Declare the variable
      • Check the length of the “bits”.
        • If the “bits” value is “0” set that value into left subtree, if the “bits” value is “1” set the value into right subtree.
      • If the left subtree is null, leaf is detected and restart from the root.
      • Return the “result”.
    • Define “encode” method.
      • Declare and set the value.
      • Check the length of the “text”.
        • Calculate the result.
        • Return the “result”.
    • Define “getCode” method.
      • Check the “root” value is null
      • The variable “codes” is declared and allocates memory for that variable.
      • Call the “assignCode” method.
      • Return the “codes” value.
    • Define “assignCode” method.
      • Check if root of left subtree value is not null.
        • If the condition is true, calculate the left and right subtree value and call the “assignCode” method with the respective parameters.
      • Otherwise calculate the “root” element value.
    • Define “getHuffmanTree” method.
      • Create a heap to hold the trees.
      • Add the values into the heap tree.
      • If the heap tree is greater than 1, remove the smallest and next smallest weight from the tree and combine the two trees.
      • Finally return the tree.
    • Define “getCharacterFrequency” method.
      • Declare the variable.
      • The try-catch block is used to check the input file is present or not and count the number of characters in that file.
      • Return the total counts.
    • Define “TreeView” class.
      • Declare the required variables.
      • Define the constructor.
      • Define the “setTree” method.
        • Add the value.
        • Call the “repaint” method.
      • Define the “repaint” method.
        • Clear the pane
        • Display the tree recursively.
    • Define the “displayTree” method.
      • Check if the left node value is not equal to null.
        • Draw a line to the up node.
        • Draw the left subtree recursively.
      • Check if the right node value is not equal to null.
        • Draw a line to the down node.
        • Draw the left subtree recursively.
      • Display the node.
    • Define “Tree” class.
      • Declare the variable.
      • Create a tree with two subtrees,
      • Create a tree containing a leaf node.
      • Compare the trees based on their weights.
    • Define “Node” class.
      • Declare the required variables.
      • Create a default constructor.
      • Create a node with the particular weight and character.
    • Define “Heap” class.
      • Create the object for the ArrayList
      • Create the default constructor.
      • Create a heap from an array of objects.
      • Define “add” method.
        • Add the new object into the heap.
        • Check the “currentIndex” value is greater than 0.
          • Swap if the current object is greater than its parents.
          • Assign “parentIndex” value into “currentIndex” variable.
      • Define “remove” method.
        • Check the condition and remove the root from the heap.
        • Declare and compute the left and right child index.
        • Then find the maximum value between two children.
        • Swap if the current node is less than maximum value.
        • Finally return the value.

Blurred answer
Students have asked these similar questions
For the control system plot root Locus and find the D gain of stability? by Matlab Ris Kp (5+3) S+5 (s+1) +CUST s(S+2) (565+18) 5-1 5²+35+4
CIS 115 Introduction to C++ May I please have a written review expressing my gratitude for a tutor that has given me guidance throughout the computer programming course? Thank you so much!
Math 130 Introduction to Java programming May I please have a written review expressing my gratitude for a tutor that has given my guidance throughout my computer programming course? Thank you
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