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.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
Write the SQL code that permits to implement the tables: Student and Transcript. NB: Add the constraints on the attributes – keys and other.
Draw an ERD that will involve the entity types: Professor, Student, Department and Course. Be sure to add relationship types, key attributes, attributes and multiplicity on the ERD.
Draw an ERD that represents a book in a library system. Be sure to add relationship types, key attributes, attributes and multiplicity on the ERD.
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