1 Announcement Change of Venue for Tutorial Session #T01 and #TA1 from Week 6 to Week 13 (except in Week 8): Section Day Time T01 & TA1 Friday 15:00 -

Slides:



Advertisements
Similar presentations
SEEM Tutorial 4 – Clustering. 2 What is Cluster Analysis?  Finding groups of objects such that the objects in a group will be similar (or.
Advertisements

Clustering (2). Hierarchical Clustering Produces a set of nested clusters organized as a hierarchical tree Can be visualized as a dendrogram –A tree like.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Integers less than 0 are (positive, negative) integers.
Advanced Algorithms Piyush Kumar (Lecture 12: Parallel Algorithms) Welcome to COT5405 Courtesy Baker 05.
Divide-and-conquer: closest pair (Chap.33) Given a set of points, find the closest pair (measured in Euclidean distance) Brute-force method: O(n 2 ). Divide-and-conquer.
Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different.
Closest Pair Design an algorithm to find the closest pair of points.
Lecture 4 Divide and Conquer for Nearest Neighbor Problem
Closest Pair Given a set S = {p1, p2,..., pn} of n points in the plane find the two points of S whose distance is the smallest. Images in this presentation.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013 Lecture 11.
Reminder: Closest-Pair Problem Given a collection P of n points in  × , obtain the two points p1 and p2 such that their distance is less or equal that.
1 Divide-and-Conquer Divide-and-conquer. n Break up problem into several parts. n Solve each part recursively. n Combine solutions to sub-problems into.
1 Today’s Material Computational Geometry Problems –Closest Pair Problem –Convex Hull Jarvis’s March, Graham’s scan –Farthest Point Problem.
Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different.
X y (x,y) x - coordinate y - coordinate. How are coordinates helpful?
Chapter 2 Section 2 The Coordinate Plane.
Warm Up Problem of the Day Lesson Presentation Lesson Quizzes.
Vocabulary coordinate plane axes x-axis
Lecture 32 CSE 331 Nov 18, HW 8 solutions Friday.
Example Input: points p 1, p 2,…,p 8 in a plane. Find a line L 1 such that 4 points are on one side and the other 4 points are.
Lecture 4: Divide and Conquer III: Other Applications and Examples Shang-Hua Teng.
5 - 1 § 5 The Divide-and-Conquer Strategy e.g. find the maximum of a set S of n numbers.
See the demo slide on the website. 4 Example 1: Whole Process H G F E D C B A Divide H G F E D C B A Merge G H E F C D A B Merge E F G H A B.
Closest Pair of Points Computational Geometry, WS 2006/07 Lecture 9, Part II Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen,
Lecture 6 Divide and Conquer for Nearest Neighbor Problem Shang-Hua Teng.
1 Comments for Assignment 1 Q1 is basic part and is also part of outcome 1. Q2 is for outcome 1. Q3 is for outcome 2. To pass outcome 1, you need to get.
Design and Analysis of Algorithms - Chapter 41 Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two.
Lecture 34 CSE 331 Nov 23, Homework related stuff Graded HW 8+9, solutions to HW 9 the week after Thanksgiving.
Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances.
Objective The student will be able to: graph ordered pairs on a coordinate plane.
30S Applied Math Mr. Knight – Killarney School Slide 1 Unit: Linear Programming Lesson: Graphing Inequalities in Two Variables Graphing Inequalities in.
Counting Inversions Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013 Lecture 12.
Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.
The Coordinate Plane Objective: Graph points on a coordinate plane.
1 Closest Pair of Points (from “Algorithm Design” by J.Kleinberg and E.Tardos) Closest pair. Given n points in the plane, find a pair with smallest Euclidean.
1 Chapter 5 Divide and Conquer Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 Chapter 5 Divide and Conquer Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Divide and Conquer Applications Sanghyun Park Fall 2002 CSE, POSTECH.
4.1 The Coordinate Plane In mathematics, points are located in reference to two perpendicular lines called axes.
CSE 421 Algorithms Lecture 15 Closest Pair, Multiplication.
Hierarchical Clustering Produces a set of nested clusters organized as a hierarchical tree Can be visualized as a dendrogram – A tree like diagram that.
Lecture 5 Today, how to solve recurrences We learned “guess and proved by induction” We also learned “substitution” method Today, we learn the “master.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 11.
Objective The student will be able to: graph ordered pairs on a coordinate plane.
Merge Sort Comparison Left Half Data Movement Right Half Sorted.
2-2 Graphing on a Coordinate Plane Warm Up Warm Up Lesson Presentation Lesson Presentation Problem of the Day Problem of the Day Lesson Quizzes Lesson.
CS 361 – Chapter 11 Divide and Conquer ! Examples: –Merge sort √ –Ranking inversions –Matrix multiplication –Closest pair of points Master theorem –A shortcut.
Ordered Pairs Objective:Find how to graph ordered pairs.
CSCE350 Algorithms and Data Structure
Chapter 5 Divide and Conquer
Punya Biswas Lecture 15 Closest Pair, Multiplication
Lecture 30 CSE 331 Nov 11, 2016.
MATH 1310 Session 1.
Lecture 33 CSE 331 Nov 19, 2012.
Master Theorem Yin Tat Lee
Richard Anderson Lecture 13 Divide and Conquer
MATH 1310 Section 1.1.
Lecture 30 CSE 331 Nov 10, 2017.
Merge and Count Merge and count step.
Merge and Count Merge and count step.
Merge and Count Merge and count step.
MATH 1310 Section 1.1.
Lecture 15, Winter 2019 Closest Pair, Multiplication
SEEM4630 Tutorial 3 – Clustering.
MATH 1310 Section 1.1.
Lecture 15 Closest Pair, Multiplication
Given a list of n  8 integers, what is the runtime bound on the optimal algorithm that sorts the first eight? O(1) O(log n) O(n) O(n log n) O(n2)
Richard Anderson Lecture 13 Divide and Conquer
Presentation transcript:

1 Announcement Change of Venue for Tutorial Session #T01 and #TA1 from Week 6 to Week 13 (except in Week 8): Section Day Time T01 & TA1 Friday 15: :50 New Venue: Week 6: 9 Oct - Room 1406, Academic 2 Week 7: 16 Oct - Room 1406, Academic 2 Week 8: 23 Oct - Room 2308, Academic 2 Week 9: 30 Oct - Room 1406, Academic 2 Week 10: 6 Nov - Room 1406, Academic 2 Week 11: 13 Nov - Room 1406, Academic 2 Week 12: 20 Nov - Room 1406, Academic 2 Week 13: 27 Nov - Room 1406, Academic 2

2

3

4 See the demo slide on the website.

5 Example 1: Whole Process H G F E D C B A Divide H G F E D C B A Merge G H E F C D A B Merge E F G H A B C D Merge A B C D E F G H

6

7 (T(n/2)=2T(n/4)+n/2)

8 Example 2: Whole Process A L G O R I T H M S Divide A L G O R | J T H M S Divide A L | G O R | J T | H M S Divide A | L | G | O R | J | T | H | M S Divide A | L | G | O | R | J | T | H | M | S Merge A | L | G | O R | J | T | H | M S Merge A L | G O R | J T | H M S Merge A G L O R | H J M S T Merge A G H J L M O R S T

9 R1: g, q, p, r, m  1, 2, 3, 4, 5 R2: q, p, r, g, m  2, 3, 4, 1, 5 We can assume that the first rank is 1, 2,,…n. example

10

11

12

13

14

15

16

17 Merge and Count Process: Another example. 1, 2, 8, 10, 11, 12; 3, 4, 5, 6, 7, 9; # of inversions 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. Time for merge : O(n).

18

19

20

21

22

23

24

25

26

27

28 ((0.5  ) 2 +(0.5  ) 2 ) 0.5 =(0.5  2 ) 0.5 < 

29 Can be done in O(n) time if we sort all the points first.

30

Sort the points according to the x-coordinates and get a list ListX={p 1, …, p n }. Closest-Pair(p 1, …, p n ) { Compute separation line L such that half the points List1X={p 1, p 2, …, P 0.5n } are on one side and the other half List2X={p 0.5n+1, …p n } on the other side. (  1, List1Y) = Closest-Pair(List1X) ; (  2, LIst2Y)= Closest-Pair(List2X) (  = min((  1,  2)) Merge: merge List1Y and list2Y to form ListY. (O(n) time) Delete all points further than  from separation line L (O(n) time) Create array new-yg for remaining points sorted by y according to ListY (O(n) time). for (i=0; i<= size of new-yg; i++) for (j=1; j<=11; j++) (the nested loop takes O(n) time) if (d(new-yg[i], new-yg[i+j]<  ) then  =d(new-yg[i], new-yg[j]; return ( , ListY). }

32 Example 1 Input: points p 1, p 2,…,p 8 in a plane. p 1 =(1,4), p 2 =(2,5), p 3 =(4,2), p 4 =(7,2), p 5 =(10,3), p 6 =(13,4),p 7 =(14,4), p 8 =(15,3) p2p2 p3p3 p1p1 p4p4 p7p7 p8p8 p6p6 p5p

33 Find a line L 1 such that 4 points are on one side and the other 4 points are on the other side. p2p2 p3p3 p1p1 p4p4 p7p7 p8p8 p6p6 p5p L1L1

34 Consider the left four points p 1,p 2,p 3,p 4. Find a line L 2 such that 2 points are on one side and the other 2 points are on the other side. δ 1 =Closest-pair (Region 1) = dist(p 1,p 2 ) =. δ 2 =Closest- pair (Region 2) = dist(p 3,p 4 ) = 3 δ=min(δ 1,δ 2 )= p2p2 p3p3 p1p1 p4p4 p7p7 p8p8 p6p6 p5p L1L1 L2L2 Reg 1 Reg 2 3

35 Delete the points in Region 1 and 2 further than δ= from L 2 Compare the distance dist(p 1,p 3 ) with δ. Here dist(p 1,p 3 ) = > δ, δ is not updated. Closest-pair (Region 1 and 2) = dist(p 1,p 2 ) =. p3p3 p1p1 p4p4 p7p7 p8p8 p6p6 p5p L1L1 L2L2 Reg 1 Reg 2

36 For the four points p 5,p 6,p 7,p 8, we use a line L 3 to divide them and use similar method to find δ 1 = Closest-pair (Region 3) = dist(p 5,p 6 ) = δ 2 =Closest- pair (Region 4) = dist(p 7,p 8 ) = δ= min(δ 1,δ 2 )= p2p2 p3p3 p1p1 p4p4 p7p7 p8p8 p6p6 p5p L1L1 L2L2 Reg 1 Reg 2 L3L3 Reg 3Reg 4

37 Delete the points in Region 1 and 2 further than δ= from L 3 Compare the distance dist(p 6,p 8 ) with δ. Here dist(p 6,p 8 ) = >δ, δ is not updated. Compare the distance dist(p 6,p 7 ) with δ. Here dist(p 6,p 7 ) = 1 < δ, δ is updated. Closest-pair (Region 3 and 4) = dist(p 6,p 7 ) = 1. p2p2 p3p3 p1p1 p4p4 p7p7 p8p8 p6p6 p5p L1L1 L2L2 Reg 1 Reg 2 L3L3 Reg 3Reg 4 1

38 Consider Region 1, 2 and Region 3, 4 as two large regions. δ 1 =Closest-pair (Region 1 and 2) = dist(p 1,p 2 ) = δ 2 =Closest- pair (Region 3 and 4) = dist(p 6,p 7 ) = 1 δ= min(δ 1,δ 2 )= 1 p2p2 p3p3 p1p1 p4p4 p7p7 p8p8 p6p6 p5p L1L1 L2L2 Reg 1 Reg 2 L3L3 Reg 3Reg 4 1

39 Delete the points in Region 1, 2, 3 and 4 further than δ= 1 from L 1 Here only one point p4 is left, δ is not updated. Closest-pair (Region 1, 2, 3 and 4) = dist(p 6,p 7 ) = 1. p2p2 p3p3 p1p1 p4p4 p7p7 p8p8 p6p6 p5p L1L1 L2L2 Reg 1 Reg 2 L3L3 Reg 3Reg 4 1

40 Closest pair of points Question: How to handle the case, where two points can have the same x-coordinate? For those points with the same x-coordinates, sort them based on y-coordinates.