Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in Java to implement a d-heap data structure that supports the following operations: deleteMin (and percolate down) insert buildHeap The value of

Write a program in Java to implement a d-heap data structure that supports the following operations:

deleteMin (and percolate down)

insert

buildHeap

The value of 'd' is input by the user. A sample inputis given below.

Enter heap elements: 31 16 24 21 13

Enter d: 2

Output: Heap (d=2): 13 16 24 31 21

Press 1) for insert, 2) for deleteMin, 3) for new d value, 4) to quit

Enter choice: 1

Enter element to insert: 6

Output: Heap (d=2): 6 16 13 31 21 24

Press 1) for insert, 2) for deleteMin, 3) for new d value, 4) to quit

Enter choice: 1

Enter element to insert: 20

Output: Heap (d=2): 6 16 13 31 21 24 20

Press 1) for insert, 2) for deleteMin, 3) for new d value, 4) to quit

Enter choice: 2

Output: Heap (d=2): 13 16 20 31 21 24

Enter choice: 3

Enter d: 3

Output: Heap (d=3): 13 16 20 31 21 24

Press 1) for insert, 2) for deleteMin, 3) for new d value, 4) to quit

Enter choice: 3

Enter d: 4

Output: Heap with d=4: 13 16 20 31 21 24

Press 1) for insert, 2) for deleteMin, 3) for new d value, 4) to quit

Enter choice: 4

Program Terminated

Note: Program will be tested with a larger heap with more elements and different d values.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

=+For a different audience? In another tone of voice?

Answered: 1 week ago