Question
Book Icon
Chapter 23, Problem 23.7PE
Program Plan Intro

Min-heap

Program Plan:

Filename: Sorting.java

  • Import the required packages.
  • Create a class “Sorting”:
    • Define the main method
      • Generate the heap and initialize the heap elements.
      • Validate the size and the remove the elements from the heap.

Filename: MinHeap.java

  • Define the class “minHeap”
    • Create a new array list.
    • Create a method “MinHeap()”.
      • Define a method “MinHeap()”.
        • Loop that iterates to add all the elements into the heap.
      • Define a method “add()”
        • Add the objects into the list.
        • Assign the current index value.
        • Loop that validates the index value is greater than zero.
        • Based on the requirements and condition defined swap is made on the list.
        • Finally elements are added into the list
      • Define the method “remove()”
        • Validates the size of list.
        • Initialize the remove object.
        • Loop that iterates to validate the index value is greater the size of the list.
        • Based on the requirements and condition defined swap is made on the list.
        • Finally the required element is removed from the list.
      • Define the method “getsize()”
        • Used to return the size of the list.

Blurred answer
Students have asked these similar questions
Node.js, Express, and Nunjucks Templates?
CIT244 Program Project 3 Assignment As with any assigned program, do not wait until the last minute to start. Start early in the week the program is due so you can ask questions if you get stuck Node.js and Express and Nunjucks Templates We have gotten to the good stuff. There is a program similar to this assignment given as the last example in the lecture notes for the week that discusses node static files. This program will take more time that previous assignments. There are several examples you should study first, particularly the pizza order example program available in the examples programs folder for the week discussing static files. You should study and run the pizza order program before trying this program. The pseudo-company is called Sun or Fun, which offers cheap flights from Louisville to either Miami or Vegas. Here's a video of how it should work. NOTE: You will hear or see references to Handlebars in this video. We used to use Handlebars, but it will be Nunjucks that we…
how to write the expression for the output
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage