DAA Final Assignment - 21aml-5
DAA Final Assignment - 21aml-5
Problem 1:
Drunken Donuts, a new wine-and-donuts restaurant chain, wants to build restaurants on many
street corners with the goal of maximizing their total profit.
The street network is described as an undirected graph G = (V, E), where the potential restaurant
sites are the vertices of the graph. Each vertex u has a nonnegative integer value pu, which
describes
the potential profit of site u. Two restaurants cannot be built on adjacent vertices (to avoid self-
competition). You are supposed to design an algorithm that outputs the chosen set U ⊆ V of
sites
that maximizes the total profit u∈U pu.
First, for parts (a)–(c), suppose that the street network G is acyclic, i.e., a tree.
(a) Consider the following “greedy” restaurant-placement algorithm: Choose the highest-
profit vertex u0 in the tree (breaking ties according to some order on vertex names) and
put it into U. Remove u0 from further consideration, along with all of its neighbors in
G. Repeat until no further vertices remain.
Give a counterexample to show that this algorithm does not always give a restaurant
placement with the maximum profit.
Problem 2:
Consider an undirected graph G =(V,E) with a weight function w providing nonnegative real-
valued weights, such that the weights of all the edges are different.
(a) Prove that, under the given uniqueness assumption, G has a unique Minimum Spanning
Tree. Each of the next three parts outlines an MST algorithm for graphs with unique
edge weights. In each case, say whether this is a correct MST algorithm or not. If so,
give proof, a more detailed description of an efficient algorithm, and an analysis. If not,
give a specific counterexample. (We are omitting the point values for these parts because
we will assign more points to algorithms and fewer to counterexamples.)
The algorithm maintains a set A of edges that are known to be in the MST. Initially, A is
empty. The algorithm operates in phases; in each, it adds a batch of one or more edges
to A. Phases continue until we have a spanning tree.
Specifically, in each phase, the algorithm does the following: For each component tree C in
the forest formed by A, identify the lightest weight edge eC crossing the cut between C
and the rest of the components. After determining these edges for all component trees,
add all of the edges eC to A, in one batch.
Considering the small tank of his vehicle (20 L), answer the following question:
(a) Can you find a route from A to S with the lowest gasoil consumption? If yes, then given an
efficient algorithm.
(b) Is there a route allowing the student to go from A to S without carrying a gasoil can? If there
is more than one, which route uses the least amount of fuel?
Problem 4.
There are two Network users System A and System B. System A is sending the packet to System
B using Routers. In this network using 3 routers as vertex, i.e. R1, R2, and R3, Search
router(R1) costs u = 1 for one time. Each edge has a value does it weigh each that has been
listed in the table:
Problem 5:
Imagine a scenario where you need to get to a baseball game from your house. Along the way,
on each road, one of two things can happen. First, sometimes the road you're using is a toll
road, and you have to pay a certain amount of money. Second, sometimes someone you know
lives on that street (like a family member or a friend). Those people can give you money to
help you restock your wallet. You need to get across town, and you want to arrive across town
with as much money as possible so you can buy hot dogs. Given that you know which roads
are toll roads and which roads have people who can give you money, you can use Bellman-
Ford to help plan the optimal route.
Instead of your home, a baseball game, and streets that either take money away from you or
give money to you, Bellman-Ford looks at a weighted graph. Either it is a positive cost (like a
toll) or a negative cost (like a friend who will give you money). So, in the above graphic, a red
arrow means you have to pay money to use that road, and a green arrow means you get paid
money to use that road. In the graph, the source vertex is your home, and the target vertex is
the baseball stadium.
Q. As per the given scenario identify the problem statement and solve it.
Groups Detail
STUDENT NAME:
SEMESTER: _
BRANCH NAME: _ _
DATE OF SUBMISSION:
TOTAL PAGES:
STUDENT SIGN: