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 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
C++ PROGRAMMING (Linked list) complete the functions: You have to continue on implementing your Array List namely the following functions: Example ArrayList: [10, 30, 40, 50] void addAt(int num, int pos) This method will add the integer num to the posth position of the list. Performing addAt(20, 2) in the example list will add 20 at the 2nd position and the array will now look like this: [10, 20, 30, 40, 50] When the value of pos is greater than the size + 1 or less than one, output "Position value invalid" void removeAt(int pos) Removes the number in the posth position of the list. Performing removeAt(3) in the example list will remove the 3rd element of the list and the updated array will be: [10, 30, 50] When the value of pos is greater than the size or less than one, output "Position value invalid"   My incomplete code:   #include <cstdlib>#include <iostream>using namespace std; class ArrayList : public List { // : means "is-a" / extend    int* array;    int index;…
Java Programming [ Using Array] - 1
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