Download presentation
Presentation is loading. Please wait.
Published byDamon Duane Wright Modified over 9 years ago
1
1 Algorithms & Data Structures for games Lecture 2B Minor Games Programming
2
2 Algorithms and Data Structures Feedback previous lectures Theory: Divide and Conquer Jan Verhoeven j.verhoeven@windesheim.nl
3
3 Theory: Divide and Conquer 10.2 Divide and Conquer 10.2.2 Closest-Points Problem 10.2.3 The Selection Problem 10.2.4 Theoretical Improvements for Arithmetic Problems
4
Divide and conquer Another common technique to design algorithms. Divide: Smaller problems are solved recursively Conquer: The solution to the original problem is then formed from the solutions of the subproblems 4
5
Examples of divide and conquer Section 2.4.3: maximum subsequence sum problem Chapter 4: linear-time tree traversal strategies Chapter 7: mergesort and quicksort 5
6
10.2.2 Closest-Points Problem 6 Find the closest pair of points. (Better than O(N 2 ) of course)
7
P partitioned into P L and P R ; shortest distances are shown 7
8
Two-lane strip, containing all points considered for d c strip. δ (delta) = min(d l,d r ) 8
9
Nice Demo http://www.cs.mcgill.ca/~cs251/Closest Pair/ClosestPairApplet/ClosestPairApplet.html http://www.cs.mcgill.ca/~cs251/Closest Pair/ClosestPairApplet/ClosestPairApplet.html 9
10
10.2.3 The Selection Problem Find the k-th smallest element in a collection S of N elements. Of particular interest is the special case of finding the median. This occurs when k = N/2. Just read it when you are very interested or have a lot of free time 10
11
10.2.4 Theoretical Improvements for Arithmetic Problems Matrix Multiplication Just read it when you are very interested or have a lot of free time 11
12
12 Homework to study Homework Study Chapter 10.2 (except 10.2.3 and 10.2.4)
13
Homework (and practice preparation) 13
14
14 Homework exercise Exercise and preparation for practice: Exercise 10.16 of your study book: Write a program to implement the closest-points algorithm in a brute force approach (see study book); Please give a graphical presentation of the input set and the points of the solution; You’re free to choose your programming language: C++ or C#
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.