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
(Please Help. My professor did not teach us any of this and will not answer my emails) Design a class named Queue for storing integers. Like a stack, a queue holds elements. In a stack, the elements are retreived in a last-in-first-out fashion. In a queue, the elements are retrieved in a first-in-first-out fashion. The class contains: An int[] data field named elements that stores the int values in the queue A data field named size that stores the number of elements in the queue A constructor that creates a Queue object with defult capacity 8 The method enqueue(int v) that adds v into the queue The method empty () that returns true if the queue is empty The method getSize() that returns the size of the queue
(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