This action might not be possible to undo. Are you sure you want to continue?

**Randomized/ Graph/ Approximation
**

Algorithms

CS 510 Design and Analysis of Algorithms

Lahore University of Management Sciences

Release Date April 27, 2012

Due Date May 10, 2012 (Before Class)

Points 100

Notes:

9 Work within your group.

9 Start early (there will be no extensions)

9 Give clear and clean proofs/algorithms/arguments.

PART I: Randomized Algorithms: Problems 1 and 2 and 3 are taken from Jeff Erickson’s notes on

treaps and skip-lists, here (also on LMS):

http://www.cs.uiuc.edu/~jeffe/teaching/algorithms/notes/10-treaps.pdf

1. 15 pts Review the lecture and notes on treaps and solve the following problems:

(a) The left spine of a binary tree is a path starting at the root and following only left-child

pointers down to a leaf. What is the expected number of nodes in the left spine of an n-node

treap?

(b) What is the expected number of leaves in an n-node treap? [Hint: What is the probability that

in an n-node treap, the node with kth smallest search key is a leaf?]

(c) Prove that the expected number of proper descendants of any node in a treap is exactly equal

to the expected depth of that node.

2. 18 pts Review the lecture and notes on treaps and solve the following problems:

Recall that a priority search tree is a binary tree in which every node has both a search key and a

priority, arranged so that the tree is simultaneously a binary search tree for the keys and a min

heap for the priorities. A heater is a priority search tree in which the priorities are given by the

user, and the search keys are distributed uniformly and independently at random in the real

interval [0, 1]. Intuitively, a heater is a sort of dual treap. The following problems consider an n-

node heater T whose node priorities are the integers from 1 to n. We identify nodes in T by their

priorities; thus, ‘node 5’ means the node in T with priority 5. The min-heap property implies that

node 1 is the root of T. Finally, let i and j be integers with 1 ¸ i < ] ¸ n.

(a) Prove that in a random permutation of the (i + 1)-element set, {1,2,S, …, i, ]], elements i and

] are adjacent with probability

2

ì+1

.

(b) Prove that node i is an ancestor of node ] with probability

2

ì+1

. [Hint: Use part (a)!]

(c) What is the probability that node i is a descendant of node ]? [Hint: Don’t use part (a)!]

(d) What is the exact expected depth of node ]?

(e) Describe and analyze an algorithm to insert a new item into a heater. Express the expected

running time of the algorithm, in terms of the rank of the newly inserted item.

(f) Describe an algorithm to delete the minimum-priority item

3. 7 pts Any skip list I can be transformed into a binary search tree I(I) as follows: The root of

I(I) is the leftmost node on the highest non-empty level of I; the left and right sub-trees are

constructed recursively from the nodes to the left and to the right of the root. Let’s call the

resulting tree I(I), a skip list tree. Show that any search in T(L) is no more expensive than the

corresponding search in L. (Searching in I(I) could be considerably cheaper—why?)

PART II: Basic Graph Algorithms: Problems 4, 5 and 6 are taken from the exercise problems in

DPV chapter 3 and 4. Reading these chapters will help you solve these problems.

4. 10 pts You are given a directed graph with (possibly negative) weighted edges, in which the

shortest path between any two vertices is guaranteed to have at most k edges. Give an algorithm

that finds the shortest path between two vertices u and : in 0(k|E|) time.

5. 10 pts Give an 0(|I|

2

) algorithm for the following task.

Input: An undirected graph 0 = (I, E); edge lengthsl

c

> u; an edge c ∈ E.

Output: The length of the shortest cycle containing edge c.

6. 20 pts Problem 3.28, pg 111 DPV: An algorithm for 2SAT, using directed graphs and strongly

connected components.

PART III: Approximation Algorithms: Chapter 9 of DPV; chapter 35 of CLRS are

recommended readings.

7. 10 pts Consider the problem of partitioning the nodes of a weighted undirected graph 0 =

(I, E, w), where w is the set of positive edge weights, into two sets I

1

and I

2

, such that following

quantity (D) is maximized:

w(I

1

) = w({u, :])

u,¡∈v

1

{u,¡]∈L

w(I

2

) = w({w, x])

w,x∈v

2

{w,x]∈L

Ð = |w(I

1

) - w(I

2

)|

(a) Show that the brute-force algorithm takes exponential time.

Following is a proposed approximation algorithm:

Let u ⊆ I, be an arbitrary subset of I

WHILE (∃

0

∗

⊆v

( ||u| - |u

∗

|| = 1 AND w(u

∗

) > w(u) )

u Å u

∗

(b) Show that this is a valid approximation algorithm with α

A

= 2.

(c) Does the algorithm run in polynomial time?

8. 10 pts In problem 6 you found an algorithm for the 2SAT problem. The 3SAT problem is just an

extension of the 2SAT problem, in which a clause can have no more than 3 literals. For example,

following is an instance of the 3SAT problem:

(x

1

∨ x

2

) ∧ (x

1

∨ x

3

∨ x

4

) ∧ (x

2

) ∧ (x

2

∨ x

3

∨ x

4

)

Just as before the goal is to find an assignment of truth values to the variables such that, the who

expression becomes true. However, unlike 2SAT, 3SAT is NP-hard, which means that, no

efficient algorithm is known to solve it.

As you can see from the struct of the CNF form, for the entire expression to be true, every clause

has to be true. Give an “approximation” heuristic which will satisfy (turn true) at least half the

clauses of the formula.

9. 0 pts Read Chapter 8 of DPV, on NP-Complete problems – from pg 247 to 262. Nothing to

submit for this problem.

4. using directed graphs and strongly connected components. ∈ | | (a) Show that the brute-force algorithm takes exponential time. an edge Input: An undirected graph . 7. where is the set of positive edge weights. 6. ∈ . Following is a proposed approximation algorithm: Let ⊆ . . Reading these chapters will help you solve these problems. 10 pts Consider the problem of partitioning the nodes of a weighted undirected graph . (Searching in could be considerably cheaper—why?) PART II: Basic Graph Algorithms: Problems 4. Let’s call the resulting tree . into two sets and . . (f) Describe an algorithm to delete the minimum-priority item 3. Give an algorithm that finds the shortest path between two vertices and in | | time. 5. pg 111 DPV: An algorithm for 2SAT. in which the shortest path between any two vertices is guaranteed to have at most k edges. Show that any search in T(L) is no more expensive than the corresponding search in L. 20 pts Problem 3. ∈ .(e) Describe and analyze an algorithm to insert a new item into a heater. 5 and 6 are taken from the exercise problems in DPV chapter 3 and 4. the left and right sub-trees are constructed recursively from the nodes to the left and to the right of the root. be an arbitrary subset of 1 AND WHILE (∃ ∗ ⊆ | | | ∗ | ∗ ∗ . 10 pts You are given a directed graph with (possibly negative) weighted edges.28. such that following quantity (D) is maximized: . 0. PART III: Approximation Algorithms: Chapter 9 of DPV. . ∈ . chapter 35 of CLRS are recommended readings. 7 pts Any skip list can be transformed into a binary search tree as follows: The root of is the leftmost node on the highest non-empty level of . edge lengths Output: The length of the shortest cycle containing edge . . 10 pts Give an | | algorithm for the following task. Express the expected running time of the algorithm. ∈ . a skip list tree. in terms of the rank of the newly inserted item. .

For example. in which a clause can have no more than 3 literals. on NP-Complete problems – from pg 247 to 262. following is an instance of the 3SAT problem: ∨ ∧ ∨ ∨ ∧ ∧ ∨ ∨ Just as before the goal is to find an assignment of truth values to the variables such that. every clause has to be true. 10 pts In problem 6 you found an algorithm for the 2SAT problem. Nothing to submit for this problem. no efficient algorithm is known to solve it. for the entire expression to be true. 3SAT is NP-hard. As you can see from the struct of the CNF form. The 3SAT problem is just an extension of the 2SAT problem. However. Give an “approximation” heuristic which will satisfy (turn true) at least half the clauses of the formula. the who expression becomes true. 8.(b) Show that this is a valid approximation algorithm with α (c) Does the algorithm run in polynomial time? 2. . 0 pts Read Chapter 8 of DPV. which means that. 9. unlike 2SAT.

Sign up to vote on this title

UsefulNot useful- graph based EA
- NP Complete Assingment Problem
- Bubble Book
- gvpr.1
- Survey
- Test1 Uncut
- tmp30E5.tmp
- Evacuation of standard Young tableaux and divisors on metric graphs, by Rohit Agrawal, Vladimir Sotirov, Fan Wei
- Thesis
- Graph Adt Intro
- 2014 Cad Vanmele Algebraic Graph Statics 1399184292
- apmc00
- Daa Unit 3
- Chapter 7 Graph Their Applications
- Graph Theory
- Graph Theory
- Graph Structure in Web (Broder)
- TP3 Course Notes
- Graph Theory Conectivity
- Data Structures - 2 marks.docx
- Further Results on Product Cordial Labeling
- GT
- 10.1.1.27.1121
- Restrained Lict Domination in Graphs
- Restrained Lict Domination in Graphs
- Gabriele Mondello- Riemann surfaces, ribbon graphs and combinatorial classes
- solutions1.1
- MatchingGraphstoQuadraticEquationsActivityFreeVersion.pdf
- Paper 015
- dosSantos_MICCAI2010
- Homework+ +5

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.