Homework 3 Solution

$30.00 $24.00

Note that for all the questions below we assume m(number of edges) n(number of nodes) so you don’t need to distinguish between O(m) and O(m + n). (25 pt) Given an undirected weighted graph G with n nodes and m edges, and we have used Prim algorithm to construct a minimum spanning tree T .…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

5/5 – (2 votes)

Note that for all the questions below we assume m(number of edges) n(number of nodes) so you don’t need to distinguish between O(m) and O(m + n).

  1. (25 pt) Given an undirected weighted graph G with n nodes and m edges, and we have used Prim algorithm to construct a minimum spanning tree T . Suppose the weight of one of the tree edge ((u, v) 2 T ) is changed from w to w0, design an algorithm to verify whether T is still a minimum spanning tree. Your algorithm should run in O(m) time, and explain why your algorithm is correct. You can assume all the weights are distinct.

  1. (21 pt) Give the time complexity for the following divide-and-conquer algorithms:

Algorithm A solves the problem by dividing it into 9 subproblems of one third the size, recursively solves each subproblem, and then combines the solutions in quadratic time.

Algorithm B solves the problem of size n by recursively solving two subproblems of size n 1, and then combine the solutions in constant time.

Algorithm C solves the problem by dividing it into 5 subproblems of half the size, recursively solves each subproblem, and then combines the solutions in linear time.

3. (25pt) Consider an n-node complete binary tree T , where n = 2d 1 for some d. Each node v of T is labaled with a real number xv . You may assume that the real numbers labeling the nodes are all distinct. A node v of T is a local minimum if the label xv is less than the label xw for all nodes w that are joined to v by an edge.

You are given such a complete binary tree T , but the labeling is only specified in the following implicit way: for each node v, you can determine the value xv by probing the node v. Show how to find a local minimum of T using only O(log n) probes to the nodes of T . Explain why your algorithm is correct.

  1. (29pt) Given a list of intervals [si , fi ] for i = 1, . . . , n, please design a divide-and-conquer algorithm that returns the length of the largest overlap among all pairs of intervals. The algorithm should run in O(n log n) time. For example, if n = 3, the intervals are f[1, 6], [2, 7], [6, 8]g, then the length of the largest overlap is 4. (Hint: sort the intervals by si values, and divide them into two parts based on their si values).

  • Homework assignments are due on the exact time indicated. Please submit your homework using the Gradescope system. Email attachments or other electronic delivery methods are not acceptable. To learn how to use Gradescope, you can:

1. Watch the one-minute video with complete instructions from here:

https://www.youtube.com/watch?v=-wemznvGPfg

2. Follow the instructions to generate a PDF scan of the assignments:

http://gradescope-static-assets.s3-us-west-2.amazonaws.com/help/submitting_ hw_guide.pdf

3. Make sure you start each problem on a new page.

  • We recommend to use LATEX, LYX or other word processing software for submitting the homework. This is not a requirement but it helps us to grade the homework and give feedback. For grading, we will take into account both the correctness and the clarity. Your answer are supposed to be in a simple and understandable manner. Sloppy answers are expected to receiver fewer points.

  • Unless specified, you should justify your algorithm with proof of correctness and time complexity.

Homework 3 Solution
$30.00 $24.00