Highlights
Task:
Problem 1 - Variants of Closest Pair of Points [10 marks]
In the closest pair of points algorithm from Lecture 05, the distance function between points was standard Euclidean distance: d2(p, q) = p (p.x ? q.x) 2 + (p.y ? q.y) 2 for any two points p, q.
• (5 marks) Describe how to find the closest pair of points in O(n · log2 n) time where distance is measured according to d1(p, q) = |p.x ? q.x| + |p.y ? q.y|. Here, |a| refers to the absolute value of a. This is more commonly known as Manhattan distance. That is, you must give pseudocode for the algorithm and prove it is correct. You can use any statement or analysis from the book or lectures without re-proving it. Note: O(n · log n) is possible too and would follow from the same ideas sketched at the end of the Lecture 05 slides. But you only need to given an O(n · log2 n) algorithm.
• (3 marks) A diamond is given by a pair (p, r) where p ? R 2 and r > 0. These represent the set D(p, r) := {q ? R 2 : d1(p, q) ? r}. Try sketching the diamond with p = (0, 0) and r = 1 to see the picture. Now let D be a set of diamonds with the same value r = 1. Show how to determine if D(p, 1)?D(q, 1) 6= ? for any two distinct (p, 1),(q, 1) ? D by using the algorithm from part 1. Ultimately, your algorithm should run in O(n · log2 n) time. You do not have to write pseudocode for this part, just describe how to use the algorithm from the previous part and give a brief argument explaining why this is correct.
• (2 marks) Let S be a collection of axis-aligned squares of side length 1. Each square is given by a point p ? R 2 describing the lower left corner, the upper-right corner of this square is (p.x + 1, p.y + 1). Given a divide-and-conquer algorithm with running time O(n · log2 n) to decide if any two squares in S intersect (i.e. share at least one point in common, even if it is just a boundary point). You can simply 2-1 2-2 Assignment 2: Submit via eClass describe what needs to be changed from the first part, no need to rewrite the entire algorithm. No proof is necessary for this final part of problem 1, keep your answer brief. Note: there are other O(n·log n) algorithms for this problem that do not the divide-and-conquer approach. You must describe a divide-and-conquer algorithm.
Problem 2 - Maximum Number of Collinear Points [10 marks] Given a set of points P, your job is to find a single line passing through R 2 that the maximum number of points in P. There is an obvious O(n 3 ) algorithm for this. For each pair of points p, q ? P consider the line through them and then count how many other points of P also lie on this line. Here, you will develop a faster algorithm.
• (6 marks) - First solve this subproblem. Let p ? P and let Up = {q ? P : q.y > p.y or (q.y = p.y and q.x > p.x)} That is, all points q lying strictly above p or are at the same height as p but lie strictly to the right of p. Find the line passing through p that intersects the greatest number of points in Up. The running time of your algorithm should be O(n · log n).
• (4 marks) - Now give an O(n 2 · log n) algorithm to solve the original problem: finding the line passing through the greatest number of points in P. Prove it is correct.
Problem 3 - Dynamic Convex Hull [10 marks] Suppose you are maintaining the convex hull of a set of points P that grows over time. That is, if a point gets added to P you must immediately compute the convex hull of the new set of points. However, rather than doing it in O(|P| log |P|) time each time P is updated, your goal is to update the convex hull after each point is added in time that is linear in the size of the current convex hull. The convex hull you maintain must be a list of points H forming the convex hull of P and the points in H are listed in counterclockwise order around the hull. Throughout, you may assume that no 3 points in P are collinear, that no two points in P are identical, and that |P| ? 3 is always true. For both parts below, you should provide an argument justifying the correctness of the algorithm and the running time analysis.
• (4 marks) Suppose you already know the points H forming the convex hull of a set of points P. Given a point p /? P, show how to determine if p lies within the convex hull or not in O(|H|) time. By within the convex hull, we mean that if we drew the line segments connecting consecutive points of H to form the convex hull (including a segment between the last point in H and the first one), then p is within the convex hull if it is in the inside of the resulting convex polygon.
The above IT Assignment has been solved by our IT Assignment Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.