COMP3011: Design and Analysis of Algorithms Assignment 4 solution

\$30.00

Original Work ?
Category:

Description

5/5 - (1 vote)

1. In this question, consider the two algorithms for computing convex hulls named Graham’s scan
(the Merge-Sort-based implementation) and Jarvis’s march that were presented in Lecture 10.

Show how to define, for every positive integer n ≥ 3, a sequence of n points in the plane for which
Jarvis’s march is asymptotically faster than Graham’s scan. Also, explain why Jarvis’s march is
faster in this particular case. (2 marks)

2. Three points in the plane are called collinear if they lie on the same straight line. For example,
the three points (0, 1), (1, 3), (3, 7) are collinear.

Describe an algorithm that solves the following
problem efficiently and analyze its time complexity.

Input: A sequence Q of points in the plane.
Output: “YES” if Q contains three points that are collinear; “NO” otherwise.
Let n denote the number of points in the input, i.e., n = |Q|. To get full marks, the worst-case
running time of your algorithm must be O(n
2
lg n).

Note that two or more points in the input Q
may have the same coordinates. (3 marks)

3. Let Independent-Set and U-LCS be the two decision problems defined below. U-LCS is “unbounded” in the sense that the number of input sequences as well as the size of the alphabet that
the symbols belong to can be arbitrarily large and are not fixed in advance.

Independent-Set:
Input: A positive integer k and an undirected graph G with vertex set V and edge set E.
Output: “YES” if there exists a subset S of V with |S| ≥ k such that no two vertices in S are

The Unbounded Longest Common Subsequence Decision Problem (U-LCS):

Input: A positive integer ` and a set X of sequences of symbols.
Output: “YES” if there exists a common subsequence of X of length ≥ `; “NO” otherwise.
Independent-Set is known to be N P-complete (you do not need to show it here). Prove that
U-LCS is N P-complete. (3 marks)

4. According to question 3. above, Independent-Set is N P-complete. Is the restriction of IndependentSet to instances in which the input graph G has no cycles of length 3 still N P-complete? If yes,
give a proof; if not, describe a polynomial-time algorithm that solves it. (3 marks)
(Continued −→)
1

5. If P 6= N P, would it be possible for a decision problem to belong to P and also be N P-complete?

6. Define the following optimization problem.

Input: A connected, undirected graph G.

Output: An assignment of a direction to each edge in G such that the number of vertices with
at least one outgoing edge is as small as possible.

As an example, if the input is the undirected graph on the left then the directed graph on the
right is an optimal solution.

It has three vertices with at least one outgoing edge, and this is the
minimum possible because it’s impossible to assign directions to all the edges so that only two
vertices get outgoing edges.

Describe a polynomial-time 2-approximation algorithm for the problem. Prove that your algorithm’s approximation ratio is at most 2 and that it runs in polynomial time.

Hint: Use one of the approximation algorithms that was presented during the lectures. (3 marks)
2
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://jarviscodinghub.com/product/comp3011-design-and-analysis-of-algorithms-assignment-4-solution/", "fetch_time": 1701256771000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2023-50/segments/1700679100081.47/warc/CC-MAIN-20231129105306-20231129135306-00643.warc.gz", "warc_record_offset": 391377869, "warc_record_length": 21350, "token_count": 770, "char_count": 3213, "score": 3.515625, "int_score": 4, "crawl": "CC-MAIN-2023-50", "snapshot_type": "latest", "language": "en", "language_score": 0.9115570783615112, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00056-of-00064.parquet"}