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.11PE
Program Plan Intro

Heap clone and equals

Program Plan:

  • Import the required packages.
  • Declare and initialize the required variables.
  • Create a class “Sorting”:
    • Define the main method
      • A new heap gets defined.
      • Add the elements into the heap.
      • Compare the heap values that are generated.
  • Define the class “Heap”
    • New array list gets created.
    • New empty heap gets created.
    • 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 object clone
        • New heap gets created.
        • Clone of the array list gets created.
        • Return the clone of the heap.
      • Define the method “equals”
        • Condition to validate the heap.
        • Return true or false after validation.

Blurred answer
Students have asked these similar questions
(Heap clone and equals) Class Name: Exercise23_11Implement the clone and equals methods in the Heap class.Sample Run heap1: 6 heap2: 6 equals? true heap1: 5 heap2: 6 equals? false
(True/False): Local variables are created by adding a positive value to the stack pointer
(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
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