Algorithms and Data Structures Exam - Spring 2007, Exams of Algorithms and Programming

The instructions and problems for an exam on algorithms and data structures. The exam covers various topics such as soda supply and demand, finding a dense subgraph, completing a partial sort, and one-dimensional facility location. Students are required to answer three out of four questions, each worth 10 points. The document also specifies that algorithms should be described with correctness proofs and time analysis.

Typology: Exams

2012/2013

Uploaded on 04/08/2013

gajjrup
gajjrup 🇮🇳

4.4

(16)

52 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Comprehensive Exam Algorithms and Data Structures
Spring 2007
General directions: Answer 3 of the following 4 questions. Each problem is worth 10 points.
Before giving more detailed descriptions of algorithms, describe in a brief (1-3 sentence) para-
graph the main ideas and techniques. Complete pseudo-code is not necessary as long as you clearly
specify how the algorithm works. You may use without proof any well-known algorithms and lower
bounds for standard problems, as long as you state precisely and correctly the known result.
Give at least an informal proof for all answers; for algorithms, this should include some con-
vincing argument of correctness, and a time analysis. The time complexity of the algorithms you
present will be given some weight in your score, as well as your correctness proofs and run-time
analysis. For example, a correct O(n2) algorithm might be worth only 8 or 9 points if there is an
O(nlog n) algorithm. The exact weight of efficiency versus correctness is given after the specific
problems, if appropriate.
I. Soda supply and demand. Chez Bob has ndifferent kinds of soda and has a supply of Si
cans for each kind i. There are mcustomers, and each customer jwants to drink at most Dj
cans, but will only drink from a fixed set Cjof kinds of soda. Given these constraints, Chez
Bob wants to find an assignment giving each customer some of the cans, so as to maximize
the total number of soda cans sold.
Give an efficient algorithm for finding an optimal assignment.
II. Finding a dense subgraph. You are given an undirected graph G= (V, E) in which each
node has degree at most 2k. You want to find a dense subgraph: a subset of nodes SV
such that each node uShas edges to least kother nodes in S.
Given Gand k, show how to efficiently find a dense subgraph, if one exists.
III. Completing a partial sort. You are given an array of integers A[1 . . . n] that is partially
sorted in ascending order, in the following sense: there are only a small number, say k, of
locations at which A[i]< A[i1]. Give an efficient algorithm for completely sorting this
array; you should express its running time in terms of nand k.
IV. One-dimensional facility location. A wholesale firm serves ndifferent retail shops, all
along a main highway, with shop iat mile dialong the highway. (Distances are linear,
so a shop at diand one at djare a distance |didj|from each other.) The firm will designate
tof these shops as distribution centers; and each distribution center can serve shops up to
distance Daway.
Give an efficient algorithm for finding the maximum number of shops that can be served
(using just tdistribution centers).
1

Partial preview of the text

Download Algorithms and Data Structures Exam - Spring 2007 and more Exams Algorithms and Programming in PDF only on Docsity!

Comprehensive Exam – Algorithms and Data Structures Spring 2007

General directions: Answer 3 of the following 4 questions. Each problem is worth 10 points.

Before giving more detailed descriptions of algorithms, describe in a brief (1-3 sentence) para- graph the main ideas and techniques. Complete pseudo-code is not necessary as long as you clearly specify how the algorithm works. You may use without proof any well-known algorithms and lower bounds for standard problems, as long as you state precisely and correctly the known result.

Give at least an informal proof for all answers; for algorithms, this should include some con- vincing argument of correctness, and a time analysis. The time complexity of the algorithms you present will be given some weight in your score, as well as your correctness proofs and run-time analysis. For example, a correct O(n^2 ) algorithm might be worth only 8 or 9 points if there is an O(n log n) algorithm. The exact weight of efficiency versus correctness is given after the specific problems, if appropriate.

I. Soda supply and demand. Chez Bob has n different kinds of soda and has a supply of Si cans for each kind i. There are m customers, and each customer j wants to drink at most Dj cans, but will only drink from a fixed set Cj of kinds of soda. Given these constraints, Chez Bob wants to find an assignment giving each customer some of the cans, so as to maximize the total number of soda cans sold. Give an efficient algorithm for finding an optimal assignment.

II. Finding a dense subgraph. You are given an undirected graph G = (V, E) in which each node has degree at most 2k. You want to find a dense subgraph: a subset of nodes S ⊂ V such that each node u ∈ S has edges to least k other nodes in S. Given G and k, show how to efficiently find a dense subgraph, if one exists.

III. Completing a partial sort. You are given an array of integers A[1... n] that is partially sorted in ascending order, in the following sense: there are only a small number, say k, of locations at which A[i] < A[i − 1]. Give an efficient algorithm for completely sorting this array; you should express its running time in terms of n and k.

IV. One-dimensional facility location. A wholesale firm serves n different retail shops, all along a main highway, with shop i at mile di along the highway. (Distances are linear, so a shop at di and one at dj are a distance |di − dj | from each other.) The firm will designate t of these shops as distribution centers; and each distribution center can serve shops up to distance D away. Give an efficient algorithm for finding the maximum number of shops that can be served (using just t distribution centers).