Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given a family of intervals [a i , b i ],i= 1, ..., n, a sub-cover is subset of

ID: 3598374 • Letter: G

Question

Given a family of intervals [ai, bi],i= 1, ..., n, a sub-cover is subset of the intervals that covers the same area of the real line as the union of all the intervals. For example, in the following

picture, the gray intervals form a sub-cover consisting of 5 intervals:

You want to design an efficient algorithm that finds a sub-cover with as few intervals as possible. In the following, you may assume that (i) all the endpoints (ai, bi) are distinct, and (ii) the original set of intervals covers a contiguous segment of the real line.

(a)

Your friend suggests the following greedy approach: at each stage, add the interval with

the most length not covered by the intervals selected so far. Give an example showing

that this approach will not find the smallest sub-cover.

(b)

Give a polynomial-time algorithm to find a smallest sub-cover, given the ai’s and bi’s asinput.

(c)

What is the running time of youralgorithm? Justify.

(d)

Prove that the greedy algorithm is correct.

Explanation / Answer

package com;
public class ArraySortedPolynomial implements PolynomialInterface

{

ArraySortedPolynomial()

{

}

ArraySortedPolynomial(String pol)

{

}

@Override

public PolynomialInterface add(PolynomialInterface other) {

// TODO Auto-generated method stub

return null;

}

@Override

public PolynomialInterface subtract(PolynomialInterface other) {

// TODO Auto-generated method stub

return null;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote