Uploaded by tinajain_ec21a18_51

ADA Assignment 2 Questions 2023[1]

advertisement
Assignment Questions
1. Four villages are located at the vertices of a unit square in the
Euclidean plane. You are asked to connect them by the shortest
network of roads so that there is a path between every pair of the
villages along those roads. Find such a network.
2. For each of the following functions, indicate the class ϴ(g(n)) the
function belongs to. (Use the simplest g(n) possible in your
answers.) Prove your assertions.
(a).
(b).
3. Given a graph G and a minimum spanning tree T, suppose that
we decrease the weight of one of the edges in T. Show that T is
still a minimum spanning tree for G. More formally, let T be a
minimum spanning tree for G with edge weights given by weight
function w. Choose one edge (x, y) ∈ T and a positive number k,
and define the weight function w’ by
4. For the bottom-up dynamic programming algorithm for the
knapsack problem, prove that
(a) its time efficiency is in Θ(nW).
(b) its space efficiency is in Θ(nW).
(c) the time needed to find the composition of an optimal subset
from a filled dynamic programming table is in O (n + W).
5. Consider the problem of scheduling n jobs of known duration’s
t1, ...tn, for execution by a single processor. The jobs can be
executed in any order, one job at a time. You want to find a
schedule that minimizes the total time spent by all the jobs in the
system. The time spent by one job in the system is the sum of the
time spent by this job in waiting plus the time spent on its
6.
7.
8.
9.
execution.) Design a greedy algorithm for this problem. Does the
greedy algorithm always yield an optimal solution?
Devise an algorithm that, given a directed graph G, prints all
Hamiltonian cycles in G. If G has n vertices, your algorithm must
run in time O(n!). Analyze the running time of your algorithm.
Show that the Bellman-Ford algorithm, when run on the
constraint graph for a system Ax ≤ b of difference constraints,
minimizes the quantity (max{x_i} - min {x_i}) subject to Ax ≤ b.
Explain how this fact might come in handy if the algorithm is
used to schedule construction jobs.
Write a program for solving the assignment problem by the
branch-and-bound algorithm. Experiment with your program to
determine the average size of the cost matrices for which the
problem is solved in a given amount of time, say, 1 minute on
your computer.
Show how to express the single-source shortest-paths problem
as a product of matrices and a vector. Describe how evaluating
this product corresponds to a Bellman Ford-like algorithm.
10. Apply the bottom-up dynamic programming algorithm to the
following instance of the knapsack problem:
Download