SlideShare a Scribd company logo
CS 321. Algorithm Analysis & Design
Lecture 6
Divide and Conquer
Closest Pair
06 - 20 Jan - Divide and Conquer
Input: A set of n points given in terms of (x,y) coordinates.
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x) coordinates.
Output: The closest pair.
Compute distances
between all pairs.
Approach #0
O(n2)
Sort the points.
Sweep through adjacent pairs.
Approach 1
Time to sort + O(n)
Divide and Conquer.
Split the point set, use recursive solutions.
Approach 2
Cost of Recursion + Time to merge
Input: A set of n points given in terms of (x) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x) coordinates.
Output: The closest pair.
Closest Pair on Left - d1
Closest Pair on Right - d2
Input: A set of n points given in terms of (x) coordinates.
Output: The closest pair.
Closest Pair on Left - d1
Closest Pair on Right - d2
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
1
2
3
4
5
6
7
8
9
10
11
12
13
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
13
1
7
5
3
9
8
11
10
4
12
2
6
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
d/2
d/2
Input: A set of n points given in terms of (x,y) coordinates.
Output: The closest pair.
d/2
d/2
06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer
T(n) ≤ 2T(n/2) + O(n)
T(n) = O(n log n)

More Related Content

PDF
Understanding Reed-Solomon code
PPTX
The dev project
PPTX
PPTX
Reed Solomon encoder and decoder \ ريد سلمون
DOCX
File ...handouts complete
PPTX
Fascio di parabole
KEY
Domain & range intro presentation
Understanding Reed-Solomon code
The dev project
Reed Solomon encoder and decoder \ ريد سلمون
File ...handouts complete
Fascio di parabole
Domain & range intro presentation

What's hot (19)

PPTX
Quadraticapplications.ppt
PPTX
Math presentation on domain and range
PPTX
Iterative1
PPTX
10.5 more on language of functions x
PPT
Polynomial functionsandgraphs
PPS
Gre 403 jeopardy
PPTX
9 the basic language of functions x
PPTX
2 1 polynomials
PPTX
7.2 abs value function
PDF
Module 3 polynomial functions
PDF
Produccion escrita expresiones algebraicas
PDF
3.3 Zeros of Polynomial Functions
PPT
Polynomials Grade 10
PPTX
Algebraic functions powerpoint
PPT
PPTX
The Quadratic Function Derived From Zeros of the Equation (SNSD Theme)
PPTX
Ani agustina (a1 c011007) polynomial
PPTX
Finding zeros of a quadratic function
Quadraticapplications.ppt
Math presentation on domain and range
Iterative1
10.5 more on language of functions x
Polynomial functionsandgraphs
Gre 403 jeopardy
9 the basic language of functions x
2 1 polynomials
7.2 abs value function
Module 3 polynomial functions
Produccion escrita expresiones algebraicas
3.3 Zeros of Polynomial Functions
Polynomials Grade 10
Algebraic functions powerpoint
The Quadratic Function Derived From Zeros of the Equation (SNSD Theme)
Ani agustina (a1 c011007) polynomial
Finding zeros of a quadratic function
Ad

Similar to 06 - 20 Jan - Divide and Conquer (20)

PDF
Seminar Report (Final)
PPTX
13-closest-pair (2)-algorithmic-programming.pptx
PDF
A simple study on computer algorithms by S. M. Risalat Hasan Chowdhury
PPTX
CLOSEST PAIR (Final)
PPT
ClosestPair_Kleinberg_and_Tardos.pptx_enjoy
PDF
Closest pair problems (Divide and Conquer)
PDF
[ACM-ICPC] UVa-10245
PPT
PDF
Orthogonal Range Searching
PDF
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
PPT
ClosestPairClosestPairClosestPairClosestPair
PDF
Poscat seminar 5
PPT
Chap05alg
PPT
Chap05alg
PPTX
ACM Problem : The Closest Pair
PPTX
Algorithm Using Divide And Conquer
PPTX
Daa unit 2
PPTX
Daa unit 2
PPT
Lecture slides week14-15
PPTX
Analysis of Algorithm II Unit version .pptx
Seminar Report (Final)
13-closest-pair (2)-algorithmic-programming.pptx
A simple study on computer algorithms by S. M. Risalat Hasan Chowdhury
CLOSEST PAIR (Final)
ClosestPair_Kleinberg_and_Tardos.pptx_enjoy
Closest pair problems (Divide and Conquer)
[ACM-ICPC] UVa-10245
Orthogonal Range Searching
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
ClosestPairClosestPairClosestPairClosestPair
Poscat seminar 5
Chap05alg
Chap05alg
ACM Problem : The Closest Pair
Algorithm Using Divide And Conquer
Daa unit 2
Daa unit 2
Lecture slides week14-15
Analysis of Algorithm II Unit version .pptx
Ad

More from Neeldhara Misra (16)

PDF
Erdos Posa Theorem
PDF
15 - 12 Feb - Stable Matchings
PDF
07- 22 Jan - Divide and Conquer
PDF
10 - 29 Jan - Recursion Part 2
PDF
05 - 18 Jan - The Sorting Wrap-Up
PDF
02 - 04 Jan - Sorting (Continued)
PDF
04 - 15 Jan - Heap Sort
PDF
08 - 25 Jan - Divide and Conquer
PDF
13 - 06 Feb - Dynamic Programming
PDF
00 - 30 Dec - Introduction
PDF
01 - 01 January - Sorting
PDF
14 - 08 Feb - Dynamic Programming
PDF
11 - 03 Feb - From Recursion to Dynamic Programming
PDF
09 - 27 Jan - Recursion Part 1
PDF
04 - 15 Jan - Heap Sort
PDF
12 - 05 Feb - Dynamic Programming
Erdos Posa Theorem
15 - 12 Feb - Stable Matchings
07- 22 Jan - Divide and Conquer
10 - 29 Jan - Recursion Part 2
05 - 18 Jan - The Sorting Wrap-Up
02 - 04 Jan - Sorting (Continued)
04 - 15 Jan - Heap Sort
08 - 25 Jan - Divide and Conquer
13 - 06 Feb - Dynamic Programming
00 - 30 Dec - Introduction
01 - 01 January - Sorting
14 - 08 Feb - Dynamic Programming
11 - 03 Feb - From Recursion to Dynamic Programming
09 - 27 Jan - Recursion Part 1
04 - 15 Jan - Heap Sort
12 - 05 Feb - Dynamic Programming

Recently uploaded (20)

PDF
01-Introduction-to-Information-Management.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Computing-Curriculum for Schools in Ghana
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
master seminar digital applications in india
PPTX
Lesson notes of climatology university.
PDF
Complications of Minimal Access Surgery at WLH
PDF
Classroom Observation Tools for Teachers
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Insiders guide to clinical Medicine.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
01-Introduction-to-Information-Management.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Computing-Curriculum for Schools in Ghana
VCE English Exam - Section C Student Revision Booklet
master seminar digital applications in india
Lesson notes of climatology university.
Complications of Minimal Access Surgery at WLH
Classroom Observation Tools for Teachers
Sports Quiz easy sports quiz sports quiz
Module 4: Burden of Disease Tutorial Slides S2 2025
Supply Chain Operations Speaking Notes -ICLT Program
GDM (1) (1).pptx small presentation for students
Insiders guide to clinical Medicine.pdf
Microbial disease of the cardiovascular and lymphatic systems
PPH.pptx obstetrics and gynecology in nursing
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Renaissance Architecture: A Journey from Faith to Humanism
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

06 - 20 Jan - Divide and Conquer

  • 1. CS 321. Algorithm Analysis & Design Lecture 6 Divide and Conquer
  • 4. Input: A set of n points given in terms of (x,y) coordinates.
  • 5. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair.
  • 6. Input: A set of n points given in terms of (x) coordinates. Output: The closest pair.
  • 7. Compute distances between all pairs. Approach #0 O(n2)
  • 8. Sort the points. Sweep through adjacent pairs. Approach 1 Time to sort + O(n)
  • 9. Divide and Conquer. Split the point set, use recursive solutions. Approach 2 Cost of Recursion + Time to merge
  • 10. Input: A set of n points given in terms of (x) coordinates. Output: The closest pair.
  • 11. Input: A set of n points given in terms of (x) coordinates. Output: The closest pair.
  • 12. Input: A set of n points given in terms of (x) coordinates. Output: The closest pair. Closest Pair on Left - d1 Closest Pair on Right - d2
  • 13. Input: A set of n points given in terms of (x) coordinates. Output: The closest pair. Closest Pair on Left - d1 Closest Pair on Right - d2
  • 14. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair.
  • 15. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair. 1 2 3 4 5 6 7 8 9 10 11 12 13
  • 16. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair.
  • 17. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair. 13 1 7 5 3 9 8 11 10 4 12 2 6
  • 18. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair.
  • 19. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair.
  • 20. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair.
  • 21. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair.
  • 22. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair.
  • 23. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair. d/2 d/2
  • 24. Input: A set of n points given in terms of (x,y) coordinates. Output: The closest pair. d/2 d/2
  • 32. T(n) ≤ 2T(n/2) + O(n) T(n) = O(n log n)