0% found this document useful (0 votes)
14 views6 pages

DAA Final Assignment - 21aml-5

The assignment for DAA (21CSH-282) requires students to solve various problems related to algorithms and graph theory, focusing on maximizing profits, finding minimum spanning trees, and optimizing routes based on fuel consumption. Students must submit solutions in a specified format, including their name, course number, and collaboration details, while ensuring originality in their work. The document outlines multiple problems, each with specific tasks and requirements, to be completed by May 8, 2023.

Uploaded by

shhrutiktutor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

DAA Final Assignment - 21aml-5

The assignment for DAA (21CSH-282) requires students to solve various problems related to algorithms and graph theory, focusing on maximizing profits, finding minimum spanning trees, and optimizing routes based on fuel consumption. Students must submit solutions in a specified format, including their name, course number, and collaboration details, while ensuring originality in their work. The document outlines multiple problems, each with specific tasks and requirements, to be completed by May 8, 2023.

Uploaded by

shhrutiktutor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

DAA (21CSH-282) ASSIGNMENT

NOTE: Due Date: 8 May 2023


This assignment, like later assignments, consists of exercises and problems. Hand in solutions
to the problems only. However, we strongly advise that you work out the exercises also since
they will help you learn the course material. You are responsible for the material they cover.
Each submitted solution should start with your name, the course number, the problem
number, your recitation section, the date, and the names of any students with whom you
collaborated (maximum student in one team can be up to 5).
We will often ask you to “give an algorithm and code” to solve a problem. Your write-up should
take the form of a short essay. Start by defining the problem you are solving and stating what
your results are.
Then provide:
1. A description of the algorithm in English and, if helpful, pseudo-code.
2. A proof (or proof sketch) for the correctness of the algorithm.
3. An analysis of the running time.
4. Design a code for the algorithm with output.
5. Assignment should be in print format and Faculty ensure that the content is not copied
from the internet.
We will give full credit only for correct solutions that are described clearly.

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.

(b) Give an efficient algorithm to determine placement with maximum profit.


(c) Suppose that, in the absence of good market research, DD decides that all sites are
equally good, so the goal is simply to design a restaurant placement with the largest
number of locations. Give a simple greedy algorithm for this case, and prove its
correctness.
(d) Now suppose that the graph is arbitrary, not necessarily acyclic. Give the fastest correct
algorithm you can for solving the problem.

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.)

(b) [Batched Edge-Addition MST]

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.

(c) [Divide-and-Conquer MST]


The algorithm uses a simple Divide-and-Conquer strategy: Divide the set V of
vertices arbitrarily into disjoint sets V1 and V2, each of size roughly V/2. Define
graph G1 =(V1,E1), where E1 is the subset of E for which both endpoints are in
V1. Define G2 =(V2,E2) analogously.
Recursively find (unique) MSTs for both G1 and G2; call them T1 and T2. Then
find the (unique) lightest edge that crosses the cut between the two sets of vertices
V1 and V2, and add that to form the final spanning tree T.
(d) [Cycle-Breaking MST]
The algorithm operates in phases. In each phase, the algorithm first finds some nonempty
subset of the simple cycles in the graph. Then it identifies the heaviest edge on each cycle, and
removes all these heavy edges. Phases continue until we have a spanning tree.
Problem 3:
A Chandigarh University student visiting Africa by jeep wants to move from city A to city S.
His jeep has a capacity of 40 L of fuel. In Figure, the gasoil consumption in liters for direct
connections between all the cities is depicted.
The student’s jeep has broken down and he still wants to go from A to S. A friend leaves him
an old car with a fuel capacity of only 20 L, although it has the same consumption per 10 km
as his own. Since the capacity of the new car is lower, he wants to make sure that he will find
enough gas stations along the way. Otherwise, he will have to bring a gasoil can. Since he
would prefer not to carry it due to the space it occupies and how much it weighs, as well as the
potential risk involved, he studies the cities of the area, the roads that connect them, and the
estimated amount of fuel to cover them, as well as the locations of the gas stations. He confirms
that there are open gas stations in cities A, E, F, I, K, and M.

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:

Answer the following question:


(a) Can you find a route from A to B with the lowest hop count?
(b) Is there a route allowing System A to go from R1 to R3 without carrying a –ve edge? If
there is more than one, which route uses the least amount of hop count?

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

Group 1 Group 2 Group 3 Group 4 Group 5 Group 6 Group 7


Problem no.1 Problem no.2 Problem no.3 Problem no.4 Problem no.5 Problem no.1 Problem no.2
20BCS6260 21BCS6024 21BCS6034 21BCS6044 21BCS6053 21BCS6068 21BCS6076
21BCS11883 21BCS6025 21BCS6037 21BCS6048 21BCS6057 21BCS6069 21BCS6078
21BCS6020 21BCS6027 21BCS6038 21BCS6050 21BCS6060 21BCS6073 21BCS6079
21BCS6021 21BCS6028 21BCS6040 21BCS6051 21BCS6062 21BCS6074 21BCS6083
21BCS6023 21BCS6033 21BCS6042 21BCS6052 21BCS6066 21BCS6075 21BCS6084

Group 8 Group 9 Group 10 Group 11 Group 12 Group 13 Group 14


Problem no.3 Problem no.4 Problem no.5 Problem no.1 Problem no.2 Problem no.3 Problem no.4
21BCS6087 21BCS6096 21BCS6105 21BCS6112 21BCS6128 21BCS6134 21BCS6142
21BCS6089 21BCS6097 21BCS6107 21BCS6113 21BCS6129 21BCS6136 21BCS6143
21BCS6092 21BCS6098 21BCS6108 21BCS6116 21BCS6131 21BCS6137 21BCS6144
21BCS6094 21BCS6099 21BCS6110 21BCS6120 21BCS6132 21BCS6138 21BCS6145
21BCS6095 21BCS6102 21BCS6111 21BCS6126 21BCS6133 21BCS6140
21CSH-282/ASSIGNMENT-(II)/04/2023

ACADEMIC YEAR: 2022-2023

DESIGN AND ANALYSIS OF ALGORITHMS


(21CSH-282)
STUDENT ID:

STUDENT NAME:

SEMESTER: _

BRANCH NAME: _ _

DATE OF SUBMISSION:

TOTAL PAGES:

STUDENT SIGN:

SUBMITTED TO: MARKS:


MR.
ASSISTANT PROFESSOR FACULTY SIGN:
AIT-CSE DEPT.

APEX INSTITUTE OF TECHNOLOGY


COMPUTER SCIENCE &ENGINEERING

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy