Greedy approach-computing change for a given coin system


Question 1: This problem involves the question of computing change for a given coin system. A coin system is defined to be a sequence of coin values v1 < v2 < . . . < vn, such that v1 = 1. For example, in the U.S. coin system we have six coins with values h1, 5, 10, 25, 50, 100i. The question is what is the best way to make change for a given integer amount A.

a) Let c ≥ 2 be an integer constant. Suppose that you have a coin system where there are n types of coins of integer values v1 < v2 < . . . < vn, such that v1 = 1 and, for 1 < i ≤ n, vi = c · vi−1. (For example, for c = 3 and n = 4, an example would be h1, 3, 9, 27i.) Describe an algorithm which given n, c, and an initial amount A, outputs an n-element vector that indicates the minimum number of coins in this system that sums up to this amount. (Hint: Use a greedy approach.)

b) Given an initial amount A ≥ 0, let hm1, . . . ,mni be the number of coins output by your algorithm.

Prove that the algorithm is correct. In particular, prove the following:

i) For 1 ≤ i ≤ n, mi ≥ 0
ii) Pni=1mi · vi = A
iii) The number of coins used is as small as possible.

Prove that your algorithm is optimal (in the sense that of generating the minimum number of coins) for any such currency system.

c) Give an example of a coin system (either occurring in history, or one of your own invention) for which the greedy algorithm may fail to produce the minimum number of coins for some amount. Your coin system must have a 1-cent coin.

Question 2: You are given an undirected graph G = (V,E) in which the edge weights are highly restricted.

In particular, each edge has a positive integer weight of either {1, 2, . . . ,W}, where W is a constant (independent of the number of edges or vertices). Show that it is possible to compute the single-source shortest paths in such a graph in O(n + m) time, where n = |V | and m = |E|. (Hint: Because W is a constant, a running time of O(W(n + m)) is as good as O(n + m).)
 
Requirement: Algorithm running time needs to be in DJIKstra’s running time or better.

Question 3: You are the mayor of a beautiful city by the ocean, and your city is connected to the mainland by a set of k bridges. Your city manager tells you that it is necessary to come up with an evacuation plan in the event of a hurricane. Your idea is to add a sign at each intersection pointing the direction of the route to the closest of the k bridges. You realize that this can be modeled as a graph problem, where the street intersections are nodes, the roads are edges, and the edge weights give the driving time between two adjacent intersections. Note that some of the roads in your city are one-way roads.

a) Explain how to solve the evacuation-route problem in O(mlog n) time, where n is the number of intersections and m is the number of streets connecting two adjacent intersections. Note that the number of bridges k is not a constant, that is, it may depend on n and m. Therefore, a running time of O(k · mlog n) is not an acceptable solution. The output of your algorithm will be a labeling of the intersections, with an arrow pointing to the road to take to the closest bridge.

b) Some of the bridges can hold more capacity than others. For 1 ≤ i ≤ k, we associate a positive numeric weight ci with each bridge. To encourage people to use bridges with higher capacity, we treat distances to different bridges differently. In particular, if δ is the actual distance from some intersection to bridge i, we assign it a capacity-weighted distance of δ/ci. Therefore, the higher the bridge capacity is, the lower the weighted distance. Present an O(mlog n) time algorithm to solve the evacuation-route problem using capacity-weighted distances.
 
Additional info: Some of the bridges will be higher capacity. Their weights will be function of (distance/number of lanes) → this will give us shorter weight and we can treat it as a better route to take even though the distance is farther away.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Greedy approach-computing change for a given coin system
Reference No:- TGS01939

Expected delivery within 24 Hours