
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question

Transcribed Image Text:Q1. Implement in Java the greedy algorithm for giving change with minimum number of coins:
while (more coin-sizes && change<amount owed)
choose the largest remaining coin-size
if (adding the coin does not make the change exceed the amount owed)
then add coin to change
else delete coin-size
Design specifications:
Represent the coin denominations in a heap ADT using the PriorityQueue or the PriorityBlockingQueue class. Make
the heap independent of the application by using class IntegerCompare, implementing Comparator.
Represent the change in a set ADT using the HashMap or the TreeMap class.
• You should enter the coin denominations (any denominations, not only the "normal" denominations) and the
amount owed. The program should display the change.
Q2. Find an instance (the amount owed and the available set of coin sizes) for which your program cannot give the
change, even when this is theoretically possible.
Q3. Analyze your algorithm (worst case only). Don't forget that you are using a heap and a map (it is a good idea to
review execution times for these data structures).
Q4. Could we use other data structures instead of heap and map to improve our implementation? Give ideas and use
arguments (asymptotic time, easy to implement, etc).
Submit the source code for Q1 and the answers to Q2-Q4.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 3 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Java programming homework Please help me on Question 9.34arrow_forwardBuild a heap from the following array. Show the heap after ???????() occurred at each node. ? = [3, 5, 1, 6, 2, 0, 8, 11, 9] Perform 2 rounds of sorting (i.e., sort two largest numbers) using ????????() procedure. Show the heap and array after every round.arrow_forwardQuestion Give the sequence of the 13 keys in the array that results after inserting the sequence of 3 keys 75 31 40 into the following maximum-oriented binary heap of size 10: 93 82 77 16 59 20 69 11 13 41 Answer Your answer should be a sequence of 13 integers, separated by whitespace.arrow_forward
- Execute program maxHeap.java and heapApplication.java(Attached Screenshot): Insert the nodes listed in 95 77 43 66 64 25 44 11 10 47 to the heap. Show screenshot. Display the heap array and compare it with the array in 95 77 43 66 64 25 44 11 10 47 . What do you find out? Max Heap import java.util.*; public class maxHeap{ public int heapSize, capacity; public int[] Arr; public maxHeap(int cap) { heapSize = 0; capacity = cap; Arr = new int[cap]; } public void heapify(int parent) { int Lson, Rson, largest, temp; Lson = 2 * parent + 1; Rson = 2 * parent + 2; /* find the largest among A[parent], A[lson] and A[rson] */ if ( Lson <= heapSize - 1 && Arr[Lson] > Arr[parent] ) { largest = Lson; } else { largest = parent; } if (Rson <= heapSize - 1 && Arr[Rson] >…arrow_forwardThere is an algorithm for making the heap complete:1. Remove the node at the root.2. Move the node in the last position to the root.3. Trickle the last node down until it is below.When this algorithm is applied continually, the data is removed from theheap in sorted order. imlement the code for the Remove and TrickleDownmethods:arrow_forwardThis is Java programming! The current code for BstMaxHeap is printing names backwords. So please modify the code BstMaxHeap.java so it prints as the following: The heap is not empty; it contains 9 entries. The largest entry is Whitney Removing entries in descending order: Removing Whitney Removing Regis Removing Megan Removing Matt Removing Jim Removing Jared Removing Doug Removing Brittany Removing Brettarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education