Option2 correct.
What is the set of event points S for the sweepline algorithm for the problem of...
The intersection detection problem for a set S of n line segments is to determine whether there exists a pair of segments in S that intersect. Give a plane sweep algorithm that solves the intersection detection problem in O(nlogn) time. Prove it only requires O(nlogn) time.
In Python, design and explain algorithm and why it works. Consider the polygon problem: given a set of three or more points in the Cartesian plane, connect them with a closed path consisting of non-intersecting line segments through all of the points. Design an algorithm for this problem and determine its efficiency class. Consider the polygon problem: given a set of three or more points in the Cartesian plane, connect them with a closed path consisting of non-intersecting line segments...
1. a) Describe an O(m)-time algorithm that, given a set of S of n distinct numbers and a positive integer k c n, determines the top k numbers in s b) Describe an O(n)-time algorithm that, given a set of S of n distinct numbers and a positive integer k < n, determines the smallest k numbers in S.
Problem 1 (5+15 points) Consider the set P of n points and suppose we are given the points of P one point at a time. After receiving each point, we compute the convex hull of the points seen so far. (a) As a naive approach, we could run Graham’s scan once for each point, with a total running time of O(n2 log n). Write down the pesuedocode for this algorithm. (b) Develop an O(n2) algorithm to solve the problem. Write...
4. Ranking/Unranking Subsets. Let A be a set of n elements and set Sk(A) be the collection of all k-element subsets of A. Recall that |Sk(A)I - (a.) (8 points) Describe a ranking algorithm to rank a k-element subset of an n-element set. (b.) (8 points) Describe an unranking algorithm to unrank an integer 0 < s< [into a ithm to unrank an integer 0 S s <C) k-element subset of an n-element set. (c.) (10 points) As examples, let...
Consider the algorithm to find the closest pair of points in the plane. Let's say you wanted to generalize the algorithm to find the two closest pairs of points in the plane given a set of (unsorted) points (p1, py. Give an algorithm for finding the two distances for this pair. In the step to conquer the two subproblems, you must explain why your algorithm is guaranteed to find the correct result. You do not need to specify the best...
Input: a directed grid graph G, a set of target points S, and an integer k Output: true if there is a path through G that visits all points in S using at most k left turns A grid graph is a graph where the vertices are at integer coordinates from 0,0 to n,n. (So 0,0, 0,1, 0,2, ...0,n, 1,0, etc.) Also, all edges are between vertices at distance 1. (So 00->01, 00->10, but not 00 to any other vertex....
Let L be a set of n lines in the plane. Give an O(nlogn) time algorithm to compute an axis-parallel rectangle that contains all the intersection points of those n lines in the plane.
Problem 3: (5 2 points) Design an algorithm that takes an array of positive integers A of length n and a positive integer T as an input and finds the largest N < T such that N can be written as a sum of some elements of A and returns such a representation of N. The complexity of the algorithms has to be O(nT). For example, for A 3,7, 10 and T 19, the output is 17 7+10, because we...
4.1 4.1 Insertion Sort 4. Design 137 the a algorithm for generating the power set of a set of n elements. (The power set of a set s is the set of all the subsets of S,including empty set and S itself.) 5. Consider the following algorithm to check connectivity of graph defined by adjacency a ALGORITHM Connected (A 0...n-1, 0..n ij) Input: Adjacency matrix Alo..n 1,0. n -1) of an undirected graph G //Output: 1 (true) if G is...