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: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
Question
Book Icon
Chapter 23, Problem 23.10PE
Program Plan Intro

Heap visualization

Program Plan:

  • Import the required packages.
  • Create a class “Myclass”:
    • New heap gets created.
    • New text field gets created.
    • New heap view gets created.
    • New button gets created.
    • Using start initialize the required.
      • New hbox gets created.
      • Set the count.
      • Add the label.
      • Set the style.
      • New border pane gets created.
      • Align and position the pane.
      • Create a scene based on the defined positions.
      • Set title for the preview.
      • Display the results based on the mouse action made.
      • The node gets add and removed based on the action defined.
    • Define the class “Heap”
      • New list gets defined.
      • New heap empty gets created.
      • Define the method “Heap()”
        • Loop that iterates to add the elements into the heap.
      • Define the method “add()”
        • Add the object.
        • Loop that iterates for the values present and add them after validation.
      • Define the method “remove()”
        • Condition to validate the elements of the list
        • Loop that iterates to remove the elements present in the list.
      • Define the method “getSize()”
        • Size of the list gets returned.
    • Define the class “HeapView()”
      • Declare and define the required varibles.
      • Call the method “repaint()”
        • Clear the pane.
        • Display the tree method is called.
      • Define the method “displayTree”
        • Condition to validate the value of the heap size.
        • New circle gets created.
        • Set the fill color and stroke color.
        • Add the elements at the required position based on the validation.
        • Display the heap.
      • Define the method “connectLeftchild”
        • Define the gap.
        • Set the x and y coordinates.
        • Add the elements.
      • Define the method “connectRightchild”
        • Define the gap.
        • Set the “x” and “y” coordinates.
        • Add the elements.
    • Define the main method.
      • Initialize the call.

Blurred answer
Students have asked these similar questions
(True/False): Arrays are passed by reference to avoid copying them onto the stack
1. (Store numbers in a linked list) Write a program that lets the user enter numbers and displays numbers as described below. Use a linked list to store the numbers. Do not store duplicate numbers. Add the methods Sort, Shuffle, and Reverse to sort, shuffle, and reverse the list in the application class (driver class). Please submit the source code and bytecode.
(Algebra: perfect square ) Write a program that prompts the user to enter an integer m and find the smallest integer n such that m * n is a perfect square. (Hint: Store all smallest factors of m into an array list. n is the product of the factors that appear an odd number of times in the array list. For example, consider m = 90, store the factors 2, 3, 3, 5 in an array list. 2 and 5 appear an odd number of times in the array list. So, n is 10.) Sample Run 1 Enter an integer m: 1500 The smallest number n for m x n to be a perfect square is 15 m x n is 22500 Sample Run 2 Enter an integer m: 63 The smallest number n for m x n to be a perfect square is 7 m x n is 441 Class Name: Exercise11_17   Answer is : import java.util.Scanner; public class Squares {   public static void main(String[] args) {       Scanner scan = new Scanner(System.in); //instantiation of Scanner that will take inputs from the keyboard        //the try catch block below is for trapping error with the input       try {…
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