Assignment1 Only Question (1)
Assignment1 Only Question (1)
SE ZG519/SS ZG519
EC-1: Assignment Weightage: 20% Marks: 40
Submission Dead Line: 04th May 2025 (Sunday)12:00 Noon
Mode of Submission: Write down (preferably typed in a doc file) your answer in the space
provided and submit a scan copy of your document.
Name: ID:
A company wants to build a chain of 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 indicating 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 subset U ⊆ V of sites that maximizes the total profit ∑u∈U pu.
(a) [Marks: 5] Suppose that the street network G is acyclic, i.e., a tree. 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 u 0 from further
considerations, along with all of its neighbors in G. Repeat until no further vertices remain.
Produce two example graphs, i.e., trees, where for one graph the algorithm produces maximum
profit and for the other graph the algorithm does not produce the maximum profit. Consider having
exactly five nodes in each of the graphs.
(b) [Marks: 10] Suppose that the street network G is acyclic. Give an efficient algorithm to
determine a placement with maximum profit. Note: your algorithm should be written in plain
English and in sequence of steps.
(c) [Marks: 5+5] Apply your algorithm designed in b) on the graphs in part a) and show the results.
Your answer is expected in an appropriate graphical representation of the graph.
(d) [Marks: 5 points] Suppose that the street network G is acyclic. In the absence of a good market
research, the company decides that all sites are equally good, and the goal is simply to design a
restaurant placement with the largest number of locations. Give a simple greedy algorithm to solve
the problem. Algorithm should be written in plain English and in sequence of steps.
(e) [Marks: 5] Now suppose that the graph is arbitrary, not necessarily acyclic. Give the fastest
and correct algorithm you can for solving the problem. What is the time complexity of your
algorithm?
(f) [Marks: 5] Apply algorithm in part e) to find the solution in the following graph. Draw only
the final graph keeping the relative positions of the nodes unchanged.