이산수학(Discrete Mathematics)

Slides:



Advertisements
Similar presentations
A simple example finding the maximum of a set S of n numbers.
Advertisements

5/5/20151 Analysis of Algorithms Lecture 6&7: Master theorem and substitution method.
September 12, Algorithms and Data Structures Lecture III Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Divide-and-Conquer Recursive in structure –Divide the problem into several smaller sub-problems that are similar to the original but smaller in size –Conquer.
CS223 Advanced Data Structures and Algorithms 1 Divide and Conquer Neil Tang 4/15/2010.
CS 2210 (22C:19) Discrete Structures Advanced Counting
April 9, 2015Applied Discrete Mathematics Week 9: Relations 1 Solving Recurrence Relations Another Example: Give an explicit formula for the Fibonacci.
ADA: 4. Divide/Conquer1 Objective o look at several divide and conquer examples (merge sort, binary search), and 3 approaches for calculating their.
Algorithms Recurrences Continued The Master Method.
Algorithms Recurrences. Definition – a recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs Example.
CPSC 320: Intermediate Algorithm Design & Analysis Divide & Conquer and Recurrences Steve Wolfman 1.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Lecture 2: Divide and Conquer I: Merge-Sort and Master Theorem Shang-Hua Teng.
Recurrences The expression: is a recurrence. –Recurrence: an equation that describes a function in terms of its value on smaller functions Analysis of.
Recurrence Relations Connection to recursive algorithms Techniques for solving them.
Recurrences The expression: is a recurrence. –Recurrence: an equation that describes a function in terms of its value on smaller functions BIL741: Advanced.
Arithmetic.
Analysis of Recursive Algorithms October 29, 2014
Divide-and-Conquer 7 2  9 4   2   4   7
Mathematics Review and Asymptotic Notation
Analysis of Algorithms
Chap. 7 (c) , Michael P. Frank1 Chapter 7: Advanced Counting Techniques.
MCA 202: Discrete Mathematics Instructor Neelima Gupta
강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) 재귀 호출 (Recursion)
CS223 Advanced Data Structures and Algorithms 1 Sorting and Master Method Neil Tang 01/21/2009.
1 Computer Algorithms Lecture 7 Master Theorem Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR.
Project 2 due … Project 2 due … Project 2 Project 2.
2015 년 봄학기 강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) 귀납과 재귀 (Induction and Recursion)
14.1 CompSci 102© Michael Frank Today’s topics Recurrence relationsRecurrence relations –Stating recurrences –LiHoReCoCo –Divide & conquer –Master’s method.
Recurrence Relation. Outline  What is a recurrence relation ?  Solving linear recurrence relations  Divide-and-conquer algorithms and recurrence relations.
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
Module #17: Recurrence Relations Rosen 5 th ed., §
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics)  정수와 나눗셈 (The Integers and Division)
이산수학 (Discrete Mathematics) 3.5 재귀 알고리즘 (Recursive Algorithms) 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과.
DR. NAVEED AHMAD DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF PESHAWAR LECTURE-5 Advance Algorithm Analysis.
10/25/20151 CS 3343: Analysis of Algorithms Lecture 6&7: Master theorem and substitution method.
Divide & Conquer  Themes  Reasoning about code (correctness and cost)  recursion, induction, and recurrence relations  Divide and Conquer  Examples.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
7.3 Divide-and-Conquer Algorithms and Recurrence Relations If f(n) represents the number of operations required to solve the problem of size n, it follow.
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
Lecture 5 Today, how to solve recurrences We learned “guess and proved by induction” We also learned “substitution” method Today, we learn the “master.
Master Method Some of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Recurrences (in color) It continues…. Recurrences When an algorithm calls itself recursively, its running time is described by a recurrence. When an algorithm.
2012 년 봄학기 강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) 수학적 귀납법 (Mathematical Induction)
Introduction to Algorithms: Divide-n-Conquer Algorithms
Introduction to Algorithms
Mathematical Foundations (Solving Recurrence)
Modeling with Recurrence Relations
UNIT- I Problem solving and Algorithmic Analysis
Chapter 4: Divide and Conquer
Chapter 4 Divide-and-Conquer
Divide and Conquer.
Module #17: Recurrence Relations
CSCE 411 Design and Analysis of Algorithms
CS 3343: Analysis of Algorithms
T(n) = aT(n/b) + cn = a(aT(n/b/b) + cn/b) + cn 2
Algorithms and Data Structures Lecture III
Divide-and-Conquer 7 2  9 4   2   4   7
Module #17: Recurrence Relations
CSE 2010: Algorithms and Data Structures
Divide and Conquer Algorithms Part I
CS 2210 Discrete Structures Advanced Counting
Solving Recurrence Relations
Divide-and-Conquer 7 2  9 4   2   4   7
Divide-and-Conquer 7 2  9 4   2   4   7
Presentation transcript:

이산수학(Discrete Mathematics) 분할과 정복 (Divide and Conquer) 2014년 봄학기 강원대학교 컴퓨터과학전공 문양세

Time for each sub-problem Divide & Conquer Recurrence Relations Divide and Conquer Main points so far: Many types of problems are solvable by reducing a problem of size n into some number a of independent sub-problems, each of size n/b, where a1 and b>1. (많은 경우에 있어서, 크기 n의 문제를 a개의 크기 n/b의 작은 문제로 바꾸어 처리할 수 있다.) The time complexity to solve such problems is given by a recurrence relation: T(n) = a·T(n/b) + g(n) (이런 경우의 시간 복잡도는 T(n)의 점화 관계로 나타낼 수 있다.) Time for each sub-problem Time to break problem up into sub-problems

Divide & Conquer Examples Divide and Conquer Binary search: Break list into 1 sub-problem (smaller list) (so a=1) of size n/2 (so b=2). So T(n) = T(n/2)+c (g(n)=c constant) Merge sort: Break list of length n into 2 sub-lists (a=2), each of size n/2 (so b=2), then merge them, in g(n) = (n) time. So T(n) = 2T(n/2) + cn (roughly, for some c)

Fast Multiplication Example (1/3) Divide and Conquer The ordinary grade-school algorithm takes (n2) steps to multiply two n-digit numbers. (학교에서 배운 방법에 따르면, n자리인 두 수의 곱은 (n2) 스텝이 필요하다.) This seems like too much work! So, let’s find a faster multiplication algorithm! To find the product cd of two 2n-digit base-b numbers, c=(c2n-1c2n-2…c0)b and d=(d2n-1d2n-2…d0)b, first, we break c and d in half: c=bnC1+C0, d=bnD1+D0, (e.g., 4321 = 10243+21) and then... (see next slide)

Fast Multiplication Example (2/3) Divide and Conquer Zero Three multiplications, each with n-digit numbers (Factor last polynomial)

Fast Multiplication Example (3/3) Divide and Conquer Notice that the time complexity T(n) of the fast multiplication algorithm obeys the recurrence: T(2n)=3T(n)+(n) i.e., T(n)=3T(n/2)+(n) So a=3, b=2. ( The order will be reduced …) Time to do the needed adds & subtracts of n-digit and 2n-digit numbers

with a≥1, integer b>1, real c>0, d≥0. Then: The Master Theorem Divide and Conquer Consider a function f(n) that, for all n=bk for all kZ+, satisfies the recurrence relation: (n=bk 일 때, 다음 점화 관계가 성립하면) f(n) = af(n/b) + cnd with a≥1, integer b>1, real c>0, d≥0. Then: Proof of the theorem is …. omitted.

Master Theorem Examples (1/3) Divide and Conquer Recall that complexity of fast multiplication was: T(n)=3T(n/2)+(n) Thus, a=3, b=2, d=1. So a > bd, so case 3 of the master theorem applies, so: which is O(n1.58…), so the new algorithm is strictly faster than ordinary (n2) multiply!

Master Theorem Examples (2/3) Divide and Conquer 예제(Binary Search): 이진 탐색의 복잡도는 얼마인가(비교 수를 추정하라)? 이진 탐색의 점화 관계: T(n) = T(n/2)+c (n 이 짝수라 가정) 매스터 정리로 보면, a = 1, b = 2, d = 0으로서, a = 1 = bd인 두 번째 경우에 해당한다. 결국, 다음과 같은 과정에 의해 O(logn)이 된다.

Master Theorem Examples (3/3) Divide and Conquer 예제(Merge Sort): 합병 정렬의 복잡도는 얼마인가(비교 수를 추정하라)? 이진 탐색의 점화 관계: T(n) = 2T(n/2)+cn (n 이 짝수라 가정) 매스터 정리로 보면, a = 2, b = 2, d = 1로서, a = 2 = bd인 두 번째 경우에 해당한다. 결국, 다음과 같은 과정에 의해 O(nlogn)이 된다.