Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134700144
Author: Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
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.
- Check if root of left subtree value is not null.
- 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.
- Check if the left node value is not equal to null.
- 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.
Expert Solution & Answer
Trending nowThis is a popular solution!
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
Chapter 25 Solutions
Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
Ch. 25.2 - Prob. 25.2.1CPCh. 25.2 - Prob. 25.2.2CPCh. 25.2 - Prob. 25.2.3CPCh. 25.2 - Prob. 25.2.4CPCh. 25.2 - Prob. 25.2.5CPCh. 25.3 - Prob. 25.3.1CPCh. 25.3 - Prob. 25.3.2CPCh. 25.3 - Prob. 25.3.3CPCh. 25.3 - Prob. 25.3.4CPCh. 25.4 - Prob. 25.4.1CP
Ch. 25.4 - Prob. 25.4.2CPCh. 25.4 - Prob. 25.4.3CPCh. 25.4 - Prob. 25.4.4CPCh. 25.4 - Prob. 25.4.5CPCh. 25.5 - Prob. 25.5.1CPCh. 25.5 - Prob. 25.5.2CPCh. 25.5 - Prob. 25.5.3CPCh. 25.5 - Prob. 25.5.4CPCh. 25.5 - Prob. 25.5.5CPCh. 25.6 - Prob. 25.6.1CPCh. 25.6 - Prob. 25.6.2CPCh. 25.6 - Prob. 25.6.3CPCh. 25.6 - How do you replace lines 9499 in Listing 25.11...Ch. 25 - Prob. 25.1PECh. 25 - (Implement inorder traversal without using...Ch. 25 - (Implement preorder traversal without using...Ch. 25 - (Implement postorder traversal without using...Ch. 25 - Prob. 25.6PECh. 25 - Prob. 25.7PECh. 25 - (Implement bidirectional iterator) The...Ch. 25 - Prob. 25.9PECh. 25 - Prob. 25.10PECh. 25 - Prob. 25.11PECh. 25 - (Test BST) Design and write a complete test...Ch. 25 - (Modify BST using Comparator) Revise BST in...Ch. 25 - Prob. 25.15PECh. 25 - (Data compression: Huffman coding) Write a program...Ch. 25 - Prob. 25.17PECh. 25 - (Compress a file) Write a program that compresses...Ch. 25 - (Decompress a file) The preceding exercise...
Knowledge Booster
Similar questions
- Please help me translate the java code to jack codearrow_forwardTranslate the following VM commands to Assembly instructions: □ push constant 1 □ push constant 5arrow_forwardSuppose the state of the argument and local memory segments are as follows: argument local stack 0 0 9 sp-> 256 1 257 1 14 2 258 259 Now consider the following VM code: 1 push constant 2 pop local @ 3 push constant 15 4 pop local 1 5 push local 1 6 push argument 1 7 gt 8 pop local 2 9 push local 0 10 push argument 0 11 add 12 pop local 0 13 push local 1 14 push local 1 15 push constant 1 16 sub 17 add 18 pop local 1 What will be the value of local 1 after the VM code has executed?arrow_forward
- Suppose the state of the RAM is as follows and the adjacent assembly code will execute: RAM 0 3 1 2 2 0 فيا 3 6 456 5 1 4 1234567 $1 A = M A = M A = M D = M @4 M = D What will be the value of the RAM[4] following the assembly code execution?arrow_forwardPlease help me answer this , the context is for the Nand2Tetris Hack Assembly VM Emulatorarrow_forwardhelp filling this out pleasearrow_forward
- What command do I give to compile this project and run App.javaarrow_forwardTwo industries that use decision trees extensively are lenders (banks, mortgage companies, etc.) and insurance. Discuss how a decision tree is used to solve a business problem.arrow_forwardand some More lab 9 For the last lab of the term, I want you to create a practical application for your database, in which you modify it in some way, for instance, taking a new order. Since the emphasis is on the database connectivity, neither a GUI nor a web application is required. In fact, a GUI would require x2go, which I don't have at home and you probably don't either. A web interface would need to be on osiris, I could figure out some way to try it out, I guess. There are also numerous security concerns. The applications should be easy for someone like a store employee or on-line customer to use. The most common operations, such as adding a customer or renting a tool, should be implemented. These Part 1 instructions now include how to use postgresql in C as well as Java and python. The important issue of transactions and commit status is addressed here. Some previous notes about web applications, and the PHP language [Previously I wrote] Now write one more program, that updates…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education