Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

This is a theory of algorithm type of assignment. The assignment.docx/pdf will be your guide. I want you to answer questions 1 - 5 and send the updated docx back to me. If anything is done wrong, this...

1 answer below »
This is a theory of algorithm type of assignment. Theassignment.docx/pdfwill be your guide. I want you to answer questions 1 - 5 and send the updated docx back to me. If anything is done wrong, this assignment will not be considered complete/correct. You also can't plagiarize! The answers need to be completely unique.
Answered 2 days After May 05, 2022

Solution

Swapnil answered on May 07 2022
105 Votes
1
    The starting point of all lines is 0,0 which can give the origin point.
The set C contains n circles, here every circle c_i have an information about its radius r_i and its center coordinate (x_i, y_i).
Greedy rules are following:
· iterate over each circle in the set C and pick c_i.
· construct 3 lines from origin to c_i.
· iterate over other remaining circles c_j (j != i).
· choose the line L_i and remove the circles that intersect.
· continue until the plane is empty.
And this will give the solution of time complexity is O(nlogn).
Code:
struct Angle
{
int s, e;
};
vecto
int> opt_pts(vecto
Angle> &angles)
{
std::sort(angles.begin(), angles.e(), [](const Angle &a, const Angle &b) -> bool
{
return a.e < b.e;
});
vecto
int> ptss;
int pts = angles[0].e;
ptss.push_back(pts);
for (size_t i = 1; i < angles.size(); ++i)
{
if (pts < angles[i].s || pts > angles[i].e)
{
pts = angles[i].e;
ptss.push_back(pts);
}
}
return ptss;
}
int main()
{
unsigned int n;
std::cin
n;
vecto
Angle> angles(n);
for (size_t i = 0; i < angles.size(); ++i)
{
std::cin
angles[i].s
angles[i].e;
}
vecto
int> ptss = opt_pts(angles);
std::cout
ptss.size()
"\n";
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here