Advanced Algorithm Homework 4 Results and Solutions

Size: px
Start display at page:

Download "Advanced Algorithm Homework 4 Results and Solutions"

Transcription

1 Advanced Algorithm Homework 4 Results and Solutions ID Av Ex YC

2 Problem 1 (30.5-2) Given a 6-coloring of an n-object list, show how to 3-color the list in O(1) time using n processors in an EREW PRAM. Note: There are several solutions for this problem. The following is one of them. You could also make use of MIS to compute this, as some students did. Solution In a 6-coloring list, 6 colors are used to color every node in the list such that no two adjacent nodes have the same color. The 6 colors are given the following binary codes: <000,010,100, 001,011,101>. In these six (3-bit) combinations, we used three (2-bit) combinations, namely <00,01,10> and appended either 0 or 1 to the right to make the six combinations. To make a 3-color list from a 6-color list, I will remove the rightmost bit from every color and thus return it to the original combination <00,01,10>. Notice the following: Consider two adjacent nodes n i and n i+1 in the list. Assume n i s color = <x 1 x 2 x 3 > and n i+1 s color = <y 1 y 2 y 3 >. We know that these two colors are different (the list is colored). If the rightmost bits in the two colors were equal (i.e. x 3 = y 3 ), then the rest of the two colors must be different (i.e. <x 1 x 2 > <y 1 y 2 >) The algorithm proceeds as follows: Assign processor P i (i=1, 2,,n) to every node i in the list For each processor P i, in Parallel Do if i is even (i.e. i mod 2 == 0) then Do // Assume P i s color = <x 1 x 2 x 3 > and P i+1 s color = <y 1 y 2 y 3 > if (x 3 == y 3 ) then P i s new_color = <x 1 x 2 > P i+1 s new_color = <y 1 y 2 > Else //pick either x 1 or x 2 (the one opposite to x 3 ) and swap it with x 3 If (x 1!= x 3 ) then swap(x 1,x 3 ) else swap(x 2,x 3 ) //after the swap operation we guarantee that x 3 == y 3 P i s new_color = <x 1 x 2 > P i+1 s new_color = <y 1 y 2 > After this part of the algorithm finishes, the list is half compatible, which means that every even node i is compatible with the odd node that follows it as shown in the following figure. 2

3 Resolve compatibility from for even to odd pairs of nodes. The next part of the algorithm resolves the compatibility with the rest of the nodes: For each processor P i, in Parallel Do if i is odd (i.e. i mod 2 == 1) then Do // Assume P i s new_color = <x 1 x 2 > and P i+1 s new_color = <y 1 y 2 > if (<x 1 x 2 >!= <y 1 y 2 >) then The two colors are compatible (don t do anything) Else Pick two new combinations for P i and P i+1 nodes such that <x 1 x 2 > is compatible with <y 1 y 2 > and <x 1 x 2 > is compatible with P i-1 color and <y 1 y 2 > is compatible with P i+2 color Resolve compatibility for odd to even pairs. Time analysis: The first part is performed in parallel and has a constant number of operations; O(1). The second part is performed in parallel and has a constant number of operations; O(1). Therefore, this algorithm takes O(1) total. 3

4 Problem 2 (35.1-2) Write psuedocode to sort a sequence <p 1, p 2,,p n > of n points according to their polar angles with respect to a given origin point p 0. Your procedure should take O(n lg n) time and use cross product to compare angles. Note: You have to use cross product to compare angles as specified by the problem, although there are several variants for this solution. Solution If the origin point p 0 is not the point (0,0), we need to translate all the points on the plane where p 0 becomes on the origin (0,0) We know that for any two vectors p 1 and p 2 with respect to the origin point; p 1 p 2 is the signed area of the parallelogram formed by the points (0,0), p 1, p 2, and p 1 + p 2. This area is determined by the polar angle between p 1 and p 2 and the length of p 1 and p 2. To sort the sequence of points (vectors), I will compare every vector p i to some vector p x on the x-axis, and to make this comparison fair, I will pick the point p x such that its x-value equals the x-value of the point p i (for all i). See the figure below. This way when we compute the cross product p 1 p 2 at every iteration, the resulting area can be used to compare angels between vectors. p i p x The psuedocode // I will use array A to store resulting cross product computations // assume the origin point P 0 =(x 0, y 0 ) If P 0!= (0,0) then For every point P i =(x i,y i ) where i=1 to n do P i =(x i -x 0, y i -y 0 ) //translate point p i with respect to p 0 For every point P i =(x i,y i ) where i=1 to n do P x = (x i,0) 4

5 Compute CP = p x p i A[i]= CP Call Merge_Sort(A); Return A; Correctness Notice that this psuedocode will work for the point p i above the x-axis and those points p i below the x-axis. Because, in the first case the cross product (CP) will be positive, and when CP is larger the angle is larger. In the second case, CP will be negative, and when CP is larger in the negative direction, the angle will be larger as well. p i p x is clockwise from p i, area is positive. p x p x p x is counterclockwise from p i, area is negative. p i Time analysis The first for loop takes O(n) time. The sorting takes O(n lg n) time. Total time = O(n)+O(n lg n) = O(n lg n). 5

6 Problem 3 (35.2-4) Give an O(n lg n)-time algorithm to determine whether an n-vertex polygon is simple. Solution A polygon is simple if it has no two intersecting edges. Simple polygon I will use a modified version of the Segment-Intersection algorithm as follows: Modified-Segment-Intersection(Polygon P) //input: polygon P given as a set of nodes = nodes(p) and a set of edges = edges(p). //Store the edges of P into a set of line segments S. S = edges(p); T = φ Sort the endpoints of the edges in S from left to right, breaking ties by putting points with lower y-coordinates first For each point p in the sorted list of endpoints Do If p is the left endpoint of a segment s Then INSERT(T,s) If (ABOVE(T,s) exists and intersects s) Or (BELOW(T,s) exists and intersects s) Then If intersection point p nodes(p) Then return (Non-simple) If p is the right endpoint of a segment s Then If both ABOVE(T,s) and BELOW(T,s) exist and ABOVE(T,s) intersects BELOW(T,s) Then If intersection point p nodes(p) Then return (Non-simple) DELETE(T,s) 6

7 Return (Simple) Where: INSERT(T,s): insert segment s into T. DELETE(T,s): delete segment s from T. ABOVE(T,s): return the segment immediately above segment s in T. BELOW(T,s): return the segment immediately below segment s in T. The algorithm is the same as the Segment-Intersection algorithm with the following modifications: 1- We inserted the edges of P into the set of segments S. This way we treat them as if they where independent segments. 2- When any intersection is found between any two segments, we check to see if this intersection point is a vertex on the polygon. If it is a vertex, then this intersection is ignored otherwise it is reported that P is a non-simple polygon. 3- If the for loop ends without finding any intersections (other than vertices), we report P as a simple polygon. Time analysis The algorithm has the same running time as the Segment-Intersection algorithm; The pre-sorting step takes O(n lg n) and the for loop tales O(n lg n) because we have 2n endpoints and each endpoints might take O(lg n) processing due to tree operations. Therefore, total time = 2 O(n lg n) = O(n lg n). 7

8 Problem 4 (35.3-4) Given an n-vertex, star-shaped polygon P specified by its vertices in counterclockwise order, show how to compute CH(P) in O(n) time. P The Algorithm Find the lowest node on the polygon (the one that has the smallest y- coordinate) call v 1 ; Starting from v 1 and moving counterclockwise label the n vertices of the polygon as <v 1, v 2,,v n > Stack S = φ; //start with empty stack Push (S,v 1 ); //push node v 1 onto the stack S. i = 2; While i n do v s = Top(S) //read the node on top of S into v s (don t pop) Check where the extensions of the two line segments (v s-1 v s )and (P v i )intersects, assume they intersect at point W. If W is inside the polygon then pop(s); Else Push(v i ); i = i + 1; //end if //end while Return S; //The nodes of CH(P) are all in S 8

9 Tracing the algorithm Here we will trace the first few steps of the algorithm on the example below: We pick v 1 as the lowest node and we label the rest of the nodes as follows: v 9 v 7 v 8 v 10 P v 6 v 5 v 11 v 12 v 2 v 4 v 1 v 3 Push v 1 on the stack; S = v 1 Initialize i = 2, and start the while loop: v s = Top(S) = v 1 ; The extended two line segments (v 12 v 1 ) and (P v 2 ) intersect at the point W as shown in the following figure: v 9 v 7 v 8 v 10 P v 6 v 5 v 11 v 12 v 1 v 2 W v 3 v 4 W is outside of the polygon P, so we push (v 2 ) onto the stack, S becomes = v 1, v 2. And i is incremented, i=3; Next iteration: 9

10 v s = Top(S) = v 2 ; The extended two line segments (v 1 v 2 ) and (P v 3 ) intersect at the point W as shown in the following figure: v 7 v 9 v 8 v 10 P v 6 v 5 v 11 W v 2 v 4 v 12 v 1 v 3 W is inside the polygon P, so we Pop (v 2 ) off the stack, S becomes = v 1. (i is not incremented!) Next iteration: v s = Top(S) = v 1 ; The extended two line segments (v 12 v 1 ) and (P v 3 ) intersect at the point W as shown in the following figure: v 9 v 8 v 7 v 10 P v 6 v 5 v 11 v 2 v 4 v 12 v 1 v 3 W W is outside of the polygon P, so we push (v 3 ) onto the stack, S becomes = v 1, v 3. And i is incremented, i=4. So far we know that v1 and v3 are in CH(P), we continue in the same fashion until we finish all nodes and the while terminates. When we finish, S will contain the nodes S= v 1, v 3, v 4, v 5, v 7, v 9, v 11, v 12. Time analysis Finding the lowest node will take O(n) time. The while loop will make n iterations, in each iteration we check the intersection of two segments, we perform push or pop stack operations or we check if the intersection point is inside 10

11 or outside of the polygon. All these operation takes O(1) time. Therefore, the while loop takes O(n) time. Thus, Total time = O(n)+O(n) = O(n). Problem 5 (35.4-3) The distance between two points can be defined in ways other than Euclidean. In the plane, the L m -distance between points p 1 and p 2 is given by ( x 1 x 2 m + y 1 y 2 m ) 1/m. Euclidean distance, therefore, is L 2 -distance. Modify the closest-pair algorithm to use L 1 -distance, which is also known as Manhattan distances. Note: To get full credit, you have to give your modified algorithm. It is not enough to only describe how you modified the algorithm. Solution Let Q be a set of n planner points. Pre-closet-pair(points Q){ points X = Sort_by_x_coordinates(Q); points Y = Sort_by_y_coordinates(Q); call Closest-Pair(Q, X, Y); }//end Closest-Pair(points Q, points X, points Y){ If Q 3, then { //Compute the distances between all pairs of points and report the //closest pair. Assume Q={p0, p1, p2}, where, p 0 =(x 0, y 0 ), //p 1 =(x 1, y 1 ), p 2 =(x 2, y 2 ). Compute d 0 = x 0 x 1 + y 0 y 1 Compute d 1 = x 0 x 2 + y 0 y 2 Compute d 2 = x 1 x 2 + y 1 y 2 d min = MIN (d 0, d 1, d 2 ); Return d min ; } Else{ // If Q > 3, then a Divide, Conquer & Combine approach is followed. //The divide step: Find a vertical line L, that bisects the points in P into P and P with almost equal sizes. All points in P are left of L (or on L), all points in P are right of L (or on L). Divide the array X into two arrays X and X as follows: X = contains the points of P sorted by x-coordinates. X = contains the points of P sorted by x-coordinates. Divide the array Y into two arrays Y and Y as follows: Y = contains the points of P sorted by y-coordinates. Y = contains the points of P sorted by y-coordinates. //This step is the opposite of the Merge procedure in Merge-Sort). 11

12 //The Conquer step Make first recursive call, d = Closest-Pair(P, X, Y ); Make second recursive call, d = Closest-Pair(P, X, Y ); d = MIN (d, d ); //Combine step Create a d 2d box about L. Find the array = the points of Y within distance d of L, sorted by their y-coordinates. can have at most 8 points. min = d; For each pair of points p and q in { //assume p=(x p, y p ) and q=(x q, y q ). d pq = x p x q + y p y q if (d pq < min) then min = d pq ; //end For Return min; } }//end Closest-pair. Time analysis This modified version of the closest-pair algorithm has the same running time as the original one, O(n lg n). But here we saved some time while computing the distance between points in two places: 1- When Q has three or less points, we used the L 1 -distance instead of using the Euclidean distance to get the minimum distance between theses three points. 2- During the combine step, we used the L 1 -distance instead of Euclidean distance, which will find the minimum distance among 8 points or less. In these two cases, every time we performed a distance computation, we saved two square operations and one square root operation. 12

13 Extra Credit Problem (35.1-7) Show how to compute the area of an n-vertex simple, but not necessarily convex, polygon in Θ(n) time. Note: You can solve this problem in easy way, or hard way. The basic steps in solving this problem is: 1). Partition the polygon into triangles. 2). Compute the area for each individual triangle. The easiest solution is to use cross product to compute the area for each individual triangle. For convex, all the cross products will be positive so it is clear we can simply add them together and get the area for the polygon. Surprisingly enough, the same cross product method also works for non-convex simple polygon. The signed cross product will take care everything. For example, suppose we have the following polygon. P3 P2 D P0 P4 P1 We now use P0 as starting point to divide it into triangles. The dash lines show we have triangles P 0 P 1 P 2, P 0 P 2 P 3 and P 0 P 3 P 4. Among those triangles, P 0 P 1 P 2 has a subarea P 0 DP 4 that is out of out of our non-convex polygon; P 0 P 2 P 3 has a subarea P 0 DP 3 that is out of out of our non-convex polygon. Also, we know that: area(p 0 DP 4 ) + area(p 0 DP 3 ) = area(p 0 P 3 P 4 ) 13

14 If we use cross product to compute the area, the triangle P 0 P 3 P 4 will yield a negative area. So this negative area will cancel out the two subareas that are out of our polygon when we compute the area of another two triangles. 14

Computational Geometry

Computational Geometry Lecture 1: Introduction and convex hulls Geometry: points, lines,... Geometric objects Geometric relations Combinatorial complexity Computational geometry Plane (two-dimensional), R 2 Space (three-dimensional),

More information

Geometric Algorithms. 1. Objects

Geometric Algorithms. 1. Objects Geometric Algorithms 1. Definitions 2. Line-Segment properties 3. Inner Points of polygons 4. Simple polygons 5. Convex hulls 6. Closest pair of points 7. Diameter of a point set 1. Objects 2-dimensional

More information

Lecture 3: Art Gallery Problems and Polygon Triangulation

Lecture 3: Art Gallery Problems and Polygon Triangulation EECS 396/496: Computational Geometry Fall 2017 Lecture 3: Art Gallery Problems and Polygon Triangulation Lecturer: Huck Bennett In this lecture, we study the problem of guarding an art gallery (specified

More information

CS 410/584, Algorithm Design & Analysis, Lecture Notes 8!

CS 410/584, Algorithm Design & Analysis, Lecture Notes 8! CS 410/584, Algorithm Design & Analysis, Computational Geometry! Algorithms for manipulation of geometric objects We will concentrate on 2-D geometry Numerically robust try to avoid division Round-off

More information

CS 410/584, Algorithm Design & Analysis, Lecture Notes 8

CS 410/584, Algorithm Design & Analysis, Lecture Notes 8 CS 410/584,, Computational Geometry Algorithms for manipulation of geometric objects We will concentrate on 2-D geometry Numerically robust try to avoid division Round-off error Divide-by-0 checks Techniques

More information

EXAM ELEMENTARY MATH FOR GMT: ALGORITHM ANALYSIS NOVEMBER 7, 2013, 13:15-16:15, RUPPERT D

EXAM ELEMENTARY MATH FOR GMT: ALGORITHM ANALYSIS NOVEMBER 7, 2013, 13:15-16:15, RUPPERT D SOLUTIONS EXAM ELEMENTARY MATH FOR GMT: ALGORITHM ANALYSIS NOVEMBER 7, 2013, 13:15-16:15, RUPPERT D This exam consists of 6 questions, worth 10 points in total, and a bonus question for 1 more point. Using

More information

Convex Hull Algorithms

Convex Hull Algorithms Convex Hull Algorithms Design and Analysis of Algorithms prof. F. Malucelli Villa Andrea e Ceriani Simone Outline Problem Definition Basic Concepts Bruteforce Algorithm Graham Scan Algorithm Divide and

More information

Computational geometry

Computational geometry Computational geometry Inge Li Gørtz CLRS Chapter 33.0, 33.1, 33.3. Computational Geometry Geometric problems (this course Euclidean plane). Does a set of line segments intersect, dividing plane into regions,

More information

8. Hidden Surface Elimination

8. Hidden Surface Elimination -04-8 Hidden Surface Elimination To eliminate edges and surfaces not visible to the viewer Two categories: Object space methods: Image space methods: deal with object definitions directly Order the surfaces

More information

Computational Geometry

Computational Geometry Casting a polyhedron CAD/CAM systems CAD/CAM systems allow you to design objects and test how they can be constructed Many objects are constructed used a mold Casting Casting A general question: Given

More information

Computational Geometry

Computational Geometry Motivation Motivation Polygons and visibility Visibility in polygons Triangulation Proof of the Art gallery theorem Two points in a simple polygon can see each other if their connecting line segment is

More information

1/60. Geometric Algorithms. Lecture 1: Introduction. Convex Hulls

1/60. Geometric Algorithms. Lecture 1: Introduction. Convex Hulls 1/60 Geometric Algorithms Lecture 1: Introduction Convex Hulls Geometric algorithms scope 2/60 Geometry algorithms (practice): Study of geometric problems that arise in various applications and how algorithms

More information

Cross products. p 2 p. p p1 p2. p 1. Line segments The convex combination of two distinct points p1 ( x1, such that for some real number with 0 1,

Cross products. p 2 p. p p1 p2. p 1. Line segments The convex combination of two distinct points p1 ( x1, such that for some real number with 0 1, CHAPTER 33 Comutational Geometry Is the branch of comuter science that studies algorithms for solving geometric roblems. Has alications in many fields, including comuter grahics robotics, VLSI design comuter

More information

Polygon Partitioning. Lecture03

Polygon Partitioning. Lecture03 1 Polygon Partitioning Lecture03 2 History of Triangulation Algorithms 3 Outline Monotone polygon Triangulation of monotone polygon Trapezoidal decomposition Decomposition in monotone mountain Convex decomposition

More information

Polygon decomposition. Motivation: Art gallery problem

Polygon decomposition. Motivation: Art gallery problem CG Lecture 3 Polygon decomposition 1. Polygon triangulation Triangulation theory Monotone polygon triangulation 2. Polygon decomposition into monotone pieces 3. Trapezoidal decomposition 4. Convex decomposition

More information

CS 373: Combinatorial Algorithms, Fall Name: Net ID: Alias: U 3 / 4 1

CS 373: Combinatorial Algorithms, Fall Name: Net ID: Alias: U 3 / 4 1 CS 373: Combinatorial Algorithms, Fall 2000 Homework 1 (due November 16, 2000 at midnight) Starting with Homework 1, homeworks may be done in teams of up to three people. Each team turns in just one solution,

More information

CSE 546, Fall, 2016 Homework 1

CSE 546, Fall, 2016 Homework 1 CSE 546, Fall, 2016 Homework 1 Due at the beginning of class Thursday, Sept. 15 at 2:30pm. Accepted without penalty until Friday, noon, in my mailbox in the Dept. office, third floor of Jolley. Notes about

More information

CS 532: 3D Computer Vision 14 th Set of Notes

CS 532: 3D Computer Vision 14 th Set of Notes 1 CS 532: 3D Computer Vision 14 th Set of Notes Instructor: Philippos Mordohai Webpage: www.cs.stevens.edu/~mordohai E-mail: Philippos.Mordohai@stevens.edu Office: Lieb 215 Lecture Outline Triangulating

More information

Planar convex hulls (I) Computational Geometry [csci 3250] Laura Toma Bowdoin College

Planar convex hulls (I) Computational Geometry [csci 3250] Laura Toma Bowdoin College Planar convex hulls (I) Computational Geometry [csci 3250] Laura Toma Bowdoin College Convex Hull Given a set P of points in 2D, their convex hull is the smallest convex polygon that contains all points

More information

CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk

CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk 8/29/06 CS 6463: AT Computational Geometry 1 Convex Hull Problem Given a set of pins on a pinboard and a rubber band around them.

More information

Computational Geometry. Algorithm Design (10) Computational Geometry. Convex Hull. Areas in Computational Geometry

Computational Geometry. Algorithm Design (10) Computational Geometry. Convex Hull. Areas in Computational Geometry Computational Geometry Algorithm Design (10) Computational Geometry Graduate School of Engineering Takashi Chikayama Algorithms formulated as geometry problems Broad application areas Computer Graphics,

More information

CSE 5311 Notes 13: Computational Geometry

CSE 5311 Notes 13: Computational Geometry CSE 5311 Notes 13: Computational Geometry (Last updated 4/17/17 4:39 PM) SMALLEST ENCLOSING DISK See section 4.7 of de Berg ( http://dx.doi.org.ezproxy.uta.edu/10.1007/978-3-540-77974-2 ) Algorithm MINIDISC(P)

More information

Line Arrangement. Chapter 6

Line Arrangement. Chapter 6 Line Arrangement Chapter 6 Line Arrangement Problem: Given a set L of n lines in the plane, compute their arrangement which is a planar subdivision. Line Arrangements Problem: Given a set L of n lines

More information

Graduate Algorithms CS F-19 Computational Geometry

Graduate Algorithms CS F-19 Computational Geometry Graduate Algorithms CS673-016F-19 Comutational Geometry David Galles Deartment of Comuter Science University of San Francisco 19-0: Cross Products Given any two oints 1 = (x 1,y 1 ) and = (x,y ) Cross

More information

Rasterization: Geometric Primitives

Rasterization: Geometric Primitives Rasterization: Geometric Primitives Outline Rasterizing lines Rasterizing polygons 1 Rasterization: What is it? How to go from real numbers of geometric primitives vertices to integer coordinates of pixels

More information

Problem. Input: An array A = (A[1],..., A[n]) with length n. Output: a permutation A of A, that is sorted: A [i] A [j] for all. 1 i j n.

Problem. Input: An array A = (A[1],..., A[n]) with length n. Output: a permutation A of A, that is sorted: A [i] A [j] for all. 1 i j n. Problem 5. Sorting Simple Sorting, Quicksort, Mergesort Input: An array A = (A[1],..., A[n]) with length n. Output: a permutation A of A, that is sorted: A [i] A [j] for all 1 i j n. 98 99 Selection Sort

More information

CS6100: Topics in Design and Analysis of Algorithms

CS6100: Topics in Design and Analysis of Algorithms CS6100: Topics in Design and Analysis of Algorithms Guarding and Triangulating Polygons John Augustine CS6100 (Even 2012): Guarding and Triangulating Polygons The Art Gallery Problem A simple polygon is

More information

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Divide and Conquer

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Divide and Conquer Computer Science 385 Analysis of Algorithms Siena College Spring 2011 Topic Notes: Divide and Conquer Divide and-conquer is a very common and very powerful algorithm design technique. The general idea:

More information

3D convex hulls. Computational Geometry [csci 3250] Laura Toma Bowdoin College

3D convex hulls. Computational Geometry [csci 3250] Laura Toma Bowdoin College 3D convex hulls Computational Geometry [csci 3250] Laura Toma Bowdoin College Convex Hulls The problem: Given a set P of points, compute their convex hull 2D 3D 2D 3D polygon polyhedron Polyhedron region

More information

Geometry. Zachary Friggstad. Programming Club Meeting

Geometry. Zachary Friggstad. Programming Club Meeting Geometry Zachary Friggstad Programming Club Meeting Points #i n c l u d e typedef complex p o i n t ; p o i n t p ( 1. 0, 5. 7 ) ; p. r e a l ( ) ; // x component p. imag ( ) ; // y component

More information

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005 INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET Renderer Implementation: Basics and Clipping David Carr Virtual Environments, Fundamentals Spring 2005 Feb-28-05 SMM009, Basics and Clipping 1

More information

EE/CSCI 451 Spring 2018 Homework 8 Total Points: [10 points] Explain the following terms: EREW PRAM CRCW PRAM. Brent s Theorem.

EE/CSCI 451 Spring 2018 Homework 8 Total Points: [10 points] Explain the following terms: EREW PRAM CRCW PRAM. Brent s Theorem. EE/CSCI 451 Spring 2018 Homework 8 Total Points: 100 1 [10 points] Explain the following terms: EREW PRAM CRCW PRAM Brent s Theorem BSP model 1 2 [15 points] Assume two sorted sequences of size n can be

More information

Last time. Today: Convex Hull Brute Force Inside(q,abc) Intersect(ab,cd) Orient(a,b,c).

Last time. Today: Convex Hull Brute Force Inside(q,abc) Intersect(ab,cd) Orient(a,b,c). Last time Convex Hull Brute Force Inside(q,abc) Intersect(ab,cd) Orient(a,b,c). Today: More efficient convex hull algorithms and absolute bounds. Two (of many) algorithms. One (of one) interesting reduction.

More information

Design and Analysis of Algorithms 演算法設計與分析. Lecture 7 April 15, 2015 洪國寶

Design and Analysis of Algorithms 演算法設計與分析. Lecture 7 April 15, 2015 洪國寶 Design and Analysis of Algorithms 演算法設計與分析 Lecture 7 April 15, 2015 洪國寶 1 Course information (5/5) Grading (Tentative) Homework 25% (You may collaborate when solving the homework, however when writing

More information

CS Data Structures and Algorithm Analysis

CS Data Structures and Algorithm Analysis CS 483 - Data Structures and Algorithm Analysis Lecture VI: Chapter 5, part 2; Chapter 6, part 1 R. Paul Wiegand George Mason University, Department of Computer Science March 8, 2006 Outline 1 Topological

More information

Motion Planning. O Rourke, Chapter 8

Motion Planning. O Rourke, Chapter 8 O Rourke, Chapter 8 Outline Translating a polygon Moving a ladder Shortest Path (Point-to-Point) Goal: Given disjoint polygons in the plane, and given positions s and t, find the shortest path from s to

More information

CSCE 411 Design and Analysis of Algorithms

CSCE 411 Design and Analysis of Algorithms CSCE 411 Design and Analysis of Algorithms Set 3: Divide and Conquer Slides by Prof. Jennifer Welch Spring 2014 CSCE 411, Spring 2014: Set 3 1 General Idea of Divide & Conquer 1. Take your problem and

More information

Lecture 7: Computational Geometry

Lecture 7: Computational Geometry Lecture 7: Computational Geometry CS 491 CAP Uttam Thakore Friday, October 7 th, 2016 Credit for many of the slides on solving geometry problems goes to the Stanford CS 97SI course lecture on computational

More information

A closed plane figure with at least 3 sides The sides intersect only at their endpoints. Polygon ABCDEF

A closed plane figure with at least 3 sides The sides intersect only at their endpoints. Polygon ABCDEF A closed plane figure with at least 3 sides The sides intersect only at their endpoints B C A D F E Polygon ABCDEF The diagonals of a polygon are the segments that connects one vertex of a polygon to another

More information

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer CSC 8301- Design and Analysis of Algorithms Lecture 5 Decrease and Conquer Algorithm Design Technique Decrease-and-Conquer This algorithm design technique is based on exploiting a relationship between

More information

Geometry Unit 1: Transformations in the Coordinate Plane. Guided Notes

Geometry Unit 1: Transformations in the Coordinate Plane. Guided Notes Geometry Unit 1: Transformations in the Coordinate Plane Guided Notes Standard: MGSE9 12.G.CO.1 Know precise definitions Essential Question: What are the undefined terms essential to any study of geometry?

More information

Chapter 8. Properties of Triangles and Quadrilaterals. 02/2017 LSowatsky

Chapter 8. Properties of Triangles and Quadrilaterals. 02/2017 LSowatsky Chapter 8 Properties of Triangles and Quadrilaterals 02/2017 LSowatsky 1 8-1A: Points, Lines, and Planes I can Identify and label basic geometric figures. LSowatsky 2 Vocabulary: Point: a point has no

More information

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane. Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 36 / 76 Spring 208 Instructor: Dr. Sateesh Mane c Sateesh R. Mane 208 Lecture February 25, 208 This is a collection of useful

More information

Geometry/Trigonometry Unit 5: Polygon Notes Period:

Geometry/Trigonometry Unit 5: Polygon Notes Period: Geometry/Trigonometry Unit 5: Polygon Notes Name: Date: Period: # (1) Page 270 271 #8 14 Even, #15 20, #27-32 (2) Page 276 1 10, #11 25 Odd (3) Page 276 277 #12 30 Even (4) Page 283 #1-14 All (5) Page

More information

Unit 1, Lesson 1: Moving in the Plane

Unit 1, Lesson 1: Moving in the Plane Unit 1, Lesson 1: Moving in the Plane Let s describe ways figures can move in the plane. 1.1: Which One Doesn t Belong: Diagrams Which one doesn t belong? 1.2: Triangle Square Dance m.openup.org/1/8-1-1-2

More information

Computational Geometry Overview from Cormen, et al.

Computational Geometry Overview from Cormen, et al. UMass Lowell Computer Science 91.503 Graduate Algorithms Prof. Karen Daniels Spring, 2014 Computational Geometry Overview from Cormen, et al. Chapter 33 (with additional material from other sources) 1

More information

15. First make a parallelogram by rotating the original triangle. Then tile with the Parallelogram.

15. First make a parallelogram by rotating the original triangle. Then tile with the Parallelogram. Shapes and Designs: Homework Examples from ACE Investigation 1: Question 15 Investigation 2: Questions 4, 20, 24 Investigation 3: Questions 2, 12 Investigation 4: Questions 9 12, 22. ACE Question ACE Investigation

More information

Lesson 2 7 Graph Partitioning

Lesson 2 7 Graph Partitioning Lesson 2 7 Graph Partitioning The Graph Partitioning Problem Look at the problem from a different angle: Let s multiply a sparse matrix A by a vector X. Recall the duality between matrices and graphs:

More information

Computational Geometry Algorithmische Geometrie

Computational Geometry Algorithmische Geometrie Algorithmische Geometrie Panos Giannopoulos Wolfgang Mulzer Lena Schlipf AG TI SS 2013 !! Register in Campus Management!! Outline What you need to know (before taking this course) What is the course about?

More information

Student Name: Teacher: Date: Miami-Dade County Public Schools. Test: 9_12 Mathematics Geometry Exam 2

Student Name: Teacher: Date: Miami-Dade County Public Schools. Test: 9_12 Mathematics Geometry Exam 2 Student Name: Teacher: Date: District: Miami-Dade County Public Schools Test: 9_12 Mathematics Geometry Exam 2 Description: GEO Topic 5: Quadrilaterals and Coordinate Geometry Form: 201 1. If the quadrilateral

More information

Cross products Line segments The convex combination of two distinct points p

Cross products Line segments The convex combination of two distinct points p CHAPTER Comutational Geometry Is the branch of comuter science that studies algorithms for solving geometric roblems. Has alications in many fields, including comuter grahics robotics, VLSI design comuter

More information

CS 323 Lecture 1. Design and Analysis of Algorithms. Hoeteck Wee

CS 323 Lecture 1. Design and Analysis of Algorithms. Hoeteck Wee { CS 323 Lecture 1 } Design and Analysis of Algorithms Hoeteck Wee hoeteck@cs.qc.cuny.edu http://cs323.qwriting.org/ Algorithmic ideas are pervasive APPLICATIONS. Economics, auctions and game theory Biology,

More information

Line segment intersection. Family of intersection problems

Line segment intersection. Family of intersection problems CG Lecture 2 Line segment intersection Intersecting two line segments Line sweep algorithm Convex polygon intersection Boolean operations on polygons Subdivision overlay algorithm 1 Family of intersection

More information

Analysis of Algorithms. Unit 4 - Analysis of well known Algorithms

Analysis of Algorithms. Unit 4 - Analysis of well known Algorithms Analysis of Algorithms Unit 4 - Analysis of well known Algorithms 1 Analysis of well known Algorithms Brute Force Algorithms Greedy Algorithms Divide and Conquer Algorithms Decrease and Conquer Algorithms

More information

An angle that has a measure less than a right angle.

An angle that has a measure less than a right angle. Unit 1 Study Strategies: Two-Dimensional Figures Lesson Vocab Word Definition Example Formed by two rays or line segments that have the same 1 Angle endpoint. The shared endpoint is called the vertex.

More information

Quadrilaterals & Transformations Study Guide

Quadrilaterals & Transformations Study Guide s & Transformations Study Guide What do I need to know for the upcoming Summative Assessment? s Classifications and Properties of: o o Trapezoid o Kite o Parallelogram o Rhombus o Rectangle o Square The

More information

3D convex hulls. Computational Geometry [csci 3250] Laura Toma Bowdoin College

3D convex hulls. Computational Geometry [csci 3250] Laura Toma Bowdoin College 3D convex hulls Computational Geometry [csci 3250] Laura Toma Bowdoin College Convex Hull in 3D The problem: Given a set P of points in 3D, compute their convex hull convex polyhedron 2D 3D polygon

More information

Motivation: Art gallery problem. Polygon decomposition. Art gallery problem: upper bound. Art gallery problem: lower bound

Motivation: Art gallery problem. Polygon decomposition. Art gallery problem: upper bound. Art gallery problem: lower bound CG Lecture 3 Polygon decomposition 1. Polygon triangulation Triangulation theory Monotone polygon triangulation 2. Polygon decomposition into monotone pieces 3. Trapezoidal decomposition 4. Conex decomposition

More information

Basic Data Structures (Version 7) Name:

Basic Data Structures (Version 7) Name: Prerequisite Concepts for Analysis of Algorithms Basic Data Structures (Version 7) Name: Email: Concept: mathematics notation 1. log 2 n is: Code: 21481 (A) o(log 10 n) (B) ω(log 10 n) (C) Θ(log 10 n)

More information

Geometry Unit 6 Properties of Quadrilaterals Classifying Polygons Review

Geometry Unit 6 Properties of Quadrilaterals Classifying Polygons Review Geometry Unit 6 Properties of Quadrilaterals Classifying Polygons Review Polygon a closed plane figure with at least 3 sides that are segments -the sides do not intersect except at the vertices N-gon -

More information

9. Visible-Surface Detection Methods

9. Visible-Surface Detection Methods 9. Visible-Surface Detection Methods More information about Modelling and Perspective Viewing: Before going to visible surface detection, we first review and discuss the followings: 1. Modelling Transformation:

More information

Algorithms and Data Structures (INF1) Lecture 7/15 Hua Lu

Algorithms and Data Structures (INF1) Lecture 7/15 Hua Lu Algorithms and Data Structures (INF1) Lecture 7/15 Hua Lu Department of Computer Science Aalborg University Fall 2007 This Lecture Merge sort Quick sort Radix sort Summary We will see more complex techniques

More information

Polygon. Note: Each segment is called a side. Each endpoint is called a vertex.

Polygon. Note: Each segment is called a side. Each endpoint is called a vertex. Polygons Polygon A closed plane figure formed by 3 or more segments. Each segment intersects exactly 2 other segments at their endpoints. No 2 segments with a common endpoint are collinear. Note: Each

More information

Thus, it is reasonable to compare binary search trees and binary heaps as is shown in Table 1.

Thus, it is reasonable to compare binary search trees and binary heaps as is shown in Table 1. 7.2 Binary Min-Heaps A heap is a tree-based structure, but it doesn t use the binary-search differentiation between the left and right sub-trees to create a linear ordering. Instead, a binary heap only

More information

Vector Addition. Qty Item Part Number 1 Force Table ME-9447B 1 Mass and Hanger Set ME Carpenter s level 1 String

Vector Addition. Qty Item Part Number 1 Force Table ME-9447B 1 Mass and Hanger Set ME Carpenter s level 1 String rev 05/2018 Vector Addition Equipment List Qty Item Part Number 1 Force Table ME-9447B 1 Mass and Hanger Set ME-8979 1 Carpenter s level 1 String Purpose The purpose of this lab is for the student to gain

More information

Prof. Gill Barequet. Center for Graphics and Geometric Computing, Technion. Dept. of Computer Science The Technion Haifa, Israel

Prof. Gill Barequet. Center for Graphics and Geometric Computing, Technion. Dept. of Computer Science The Technion Haifa, Israel Computational Geometry (CS 236719) http://www.cs.tufts.edu/~barequet/teaching/cg Chapter 1 Introduction 1 Copyright 2002-2009 2009 Prof. Gill Barequet Center for Graphics and Geometric Computing Dept.

More information

Divide-and-Conquer CSE 680

Divide-and-Conquer CSE 680 Divide-and-Conquer CSE 680 1 Introduction Given an instance x of a problem, the divide-and-conquer method works as follows. function DAQ(x) if x is sufficiently small or simple then solve it directly else

More information

K-structure, Separating Chain, Gap Tree, and Layered DAG

K-structure, Separating Chain, Gap Tree, and Layered DAG K-structure, Separating Chain, Gap Tree, and Layered DAG Presented by Dave Tahmoush Overview Improvement on Gap Tree and K-structure Faster point location Encompasses Separating Chain Better storage Designed

More information

Geometric Algorithms. Geometric search: overview. 1D Range Search. 1D Range Search Implementations

Geometric Algorithms. Geometric search: overview. 1D Range Search. 1D Range Search Implementations Geometric search: overview Geometric Algorithms Types of data:, lines, planes, polygons, circles,... This lecture: sets of N objects. Range searching Quadtrees, 2D trees, kd trees Intersections of geometric

More information

(Refer Slide Time: 00:02:00)

(Refer Slide Time: 00:02:00) Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 18 Polyfill - Scan Conversion of a Polygon Today we will discuss the concepts

More information

Rasterization, or What is glbegin(gl_lines) really doing?

Rasterization, or What is glbegin(gl_lines) really doing? Rasterization, or What is glbegin(gl_lines) really doing? Course web page: http://goo.gl/eb3aa February 23, 2012 Lecture 4 Outline Rasterizing lines DDA/parametric algorithm Midpoint/Bresenham s algorithm

More information

CSE 554 Lecture 6: Fairing and Simplification

CSE 554 Lecture 6: Fairing and Simplification CSE 554 Lecture 6: Fairing and Simplification Fall 2012 CSE554 Fairing and simplification Slide 1 Review Iso-contours in grayscale images and volumes Piece-wise linear representations Polylines (2D) and

More information

Brute Force: Selection Sort

Brute Force: Selection Sort Brute Force: Intro Brute force means straightforward approach Usually based directly on problem s specs Force refers to computational power Usually not as efficient as elegant solutions Advantages: Applicable

More information

Dynamic Programming Homework Problems

Dynamic Programming Homework Problems CS 1510 Dynamic Programming Homework Problems 1. Consider the recurrence relation T(0) = T(1) = 2 and for n > 1 n 1 T(n) = T(i)T(i 1) i=1 We consider the problem of computing T(n) from n. (a) Show that

More information

Lecture 13: Divide and Conquer (1997) Steven Skiena. skiena

Lecture 13: Divide and Conquer (1997) Steven Skiena.   skiena Lecture 13: Divide and Conquer (1997) Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Problem Solving Techniques Most

More information

COMP Parallel Computing. PRAM (2) PRAM algorithm design techniques

COMP Parallel Computing. PRAM (2) PRAM algorithm design techniques COMP 633 - Parallel Computing Lecture 3 Aug 29, 2017 PRAM algorithm design techniques Reading for next class (Thu Aug 31): PRAM handout secns 3.6, 4.1, skim section 5. Written assignment 1 is posted, due

More information

Assignment 1 Introduction to Graph Theory CO342

Assignment 1 Introduction to Graph Theory CO342 Assignment 1 Introduction to Graph Theory CO342 This assignment will be marked out of a total of thirty points, and is due on Thursday 18th May at 10am in class. Throughout the assignment, the graphs are

More information

CSE 421 Closest Pair of Points, Master Theorem, Integer Multiplication

CSE 421 Closest Pair of Points, Master Theorem, Integer Multiplication CSE 421 Closest Pair of Points, Master Theorem, Integer Multiplication Shayan Oveis Gharan 1 Finding the Closest Pair of Points Closest Pair of Points (non geometric) Given n points and arbitrary distances

More information

CS4733 Class Notes. 1 2-D Robot Motion Planning Algorithm Using Grown Obstacles

CS4733 Class Notes. 1 2-D Robot Motion Planning Algorithm Using Grown Obstacles CS4733 Class Notes 1 2-D Robot Motion Planning Algorithm Using Grown Obstacles Reference: An Algorithm for Planning Collision Free Paths Among Poyhedral Obstacles by T. Lozano-Perez and M. Wesley. This

More information

Computational Geometry TOPICS Preliminaries Point in a Polygon Polygon Construction Convex Hulls

Computational Geometry TOPICS Preliminaries Point in a Polygon Polygon Construction Convex Hulls Computational Geometry TOPICS Preliminaries Point in a Polygon Polygon Construction Convex Hulls CSE5311 Kumar 1 Geometric Algorithms Geometric Algorithms find applications in such areas as Computer Graphics

More information

Cpt S 122 Data Structures. Sorting

Cpt S 122 Data Structures. Sorting Cpt S 122 Data Structures Sorting Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Sorting Process of re-arranging data in ascending or descending order Given

More information

8. Hidden Surface Elimination

8. Hidden Surface Elimination 8. Hidden Surface Elimination Identification and Removal of parts of picture that are not visible from a chosen viewing position. 1 8. Hidden Surface Elimination Basic idea: Overwriting Paint things in

More information

The divide-and-conquer paradigm involves three steps at each level of the recursion: Divide the problem into a number of subproblems.

The divide-and-conquer paradigm involves three steps at each level of the recursion: Divide the problem into a number of subproblems. 2.3 Designing algorithms There are many ways to design algorithms. Insertion sort uses an incremental approach: having sorted the subarray A[1 j - 1], we insert the single element A[j] into its proper

More information

Convex Polygon Generation

Convex Polygon Generation Convex Polygon Generation critterai.org /projects/nmgen_study/polygen.html This page describes the forth stage in building a navigation mesh, the generation of convex polygons from the simple polygons

More information

Section 12.1 Translations and Rotations

Section 12.1 Translations and Rotations Section 12.1 Translations and Rotations Any rigid motion that preserves length or distance is an isometry. We look at two types of isometries in this section: translations and rotations. Translations A

More information

Lecture 6: Divide-and-Conquer

Lecture 6: Divide-and-Conquer Lecture 6: Divide-and-Conquer COSC242: Algorithms and Data Structures Brendan McCane Department of Computer Science, University of Otago Types of Algorithms In COSC242, we will be looking at 3 general

More information

8. The triangle is rotated around point D to create a new triangle. This looks like a rigid transformation.

8. The triangle is rotated around point D to create a new triangle. This looks like a rigid transformation. 2.1 Transformations in the Plane 1. True 2. True 3. False 4. False 5. True 6. False 7. True 8. The triangle is rotated around point D to create a new triangle. This looks like a rigid transformation. 9.

More information

5.4 Closest Pair of Points

5.4 Closest Pair of Points 5.4 Closest Pair of Points Closest pair. Given n points in the plane, find a pair with smallest Euclidean distance between them. Fundamental geometric primitive. Graphics, computer vision, geographic information

More information

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer CSC 8301- Design and Analysis of Algorithms Lecture 5 Decrease and Conuer Algorithm Design Techniue Decrease-and-Conuer This algorithm design techniue is based on exploiting a relationship between a solution

More information

The resulting array is written as row i + 1 in our matrix:

The resulting array is written as row i + 1 in our matrix: Homework 5 Solutions Fundamental Algorithms, Fall 2004, Professor Yap Due: Thu December 9, in class SOLUTION PREPARED BY Instructor and T.A.s Ariel Cohen and Vikram Sharma INSTRUCTIONS: NOTICE: In the

More information

Parallel Models RAM. Parallel RAM aka PRAM. Variants of CRCW PRAM. Advanced Algorithms

Parallel Models RAM. Parallel RAM aka PRAM. Variants of CRCW PRAM. Advanced Algorithms Parallel Models Advanced Algorithms Piyush Kumar (Lecture 10: Parallel Algorithms) An abstract description of a real world parallel machine. Attempts to capture essential features (and suppress details?)

More information

Notes and Answers to Homework Exam 1, Geometric Algorithms, 2017

Notes and Answers to Homework Exam 1, Geometric Algorithms, 2017 Notes and Answers to Homework Exam 1, Geometric Algorithms, 2017 Below are some notes and sketches of correct answers for the first homework exam. We have also included the most common mistakes that were

More information

BSP Trees. Chapter Introduction. 8.2 Overview

BSP Trees. Chapter Introduction. 8.2 Overview Chapter 8 BSP Trees 8.1 Introduction In this document, we assume that the objects we are dealing with are represented by polygons. In fact, the algorithms we develop actually assume the polygons are triangles,

More information

(b) If a heap has n elements, what s the height of the tree?

(b) If a heap has n elements, what s the height of the tree? CISC 5835 Algorithms for Big Data Fall, 2018 Homework Assignment #4 1 Answer the following questions about binary tree and heap: (a) For a complete binary tree of height 4 (we consider a tree with just

More information

Chapter 5. Transforming Shapes

Chapter 5. Transforming Shapes Chapter 5 Transforming Shapes It is difficult to walk through daily life without being able to see geometric transformations in your surroundings. Notice how the leaves of plants, for example, are almost

More information

Convex Hulls in Three Dimensions. Polyhedra

Convex Hulls in Three Dimensions. Polyhedra Convex Hulls in Three Dimensions Polyhedra Polyhedron 1.A polyhedron is the generalization of a 2- D polygon to 3-D A finite number of flat polygonal faces The boundary or surface of a polyhedron - Zero-dimensional

More information

Geometric Queries for Ray Tracing

Geometric Queries for Ray Tracing CSCI 420 Computer Graphics Lecture 16 Geometric Queries for Ray Tracing Ray-Surface Intersection Barycentric Coordinates [Angel Ch. 11] Jernej Barbic University of Southern California 1 Ray-Surface Intersections

More information

Review implementation of Stable Matching Survey of common running times. Turn in completed problem sets. Jan 18, 2019 Sprenkle - CSCI211

Review implementation of Stable Matching Survey of common running times. Turn in completed problem sets. Jan 18, 2019 Sprenkle - CSCI211 Objectives Review implementation of Stable Matching Survey of common running times Turn in completed problem sets Jan 18, 2019 Sprenkle - CSCI211 1 Review: Asymptotic Analysis of Gale-Shapley Alg Not explicitly

More information

Triangulation and Convex Hull. 8th November 2018

Triangulation and Convex Hull. 8th November 2018 Triangulation and Convex Hull 8th November 2018 Agenda 1. Triangulation. No book, the slides are the curriculum 2. Finding the convex hull. Textbook, 8.6.2 2 Triangulation and terrain models Here we have

More information

Lecture 2: Divide and Conquer

Lecture 2: Divide and Conquer Lecture 2: Divide and Conquer Paradigm Convex Hull Median finding Paradigm Given a problem of size n divide it into subproblems of size n, a 1, b >1. Solve each b subproblem recursively. Combine solutions

More information