1. Trang chủ
  2. » Giáo án - Bài giảng

18 1 21 master method proof tủ tài liệu training pdf

19 54 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 19
Dung lượng 2,36 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Master MethodProof Part 1 Design and Analysis of Algorithms I... Level logbn a braches Base cases size 1ti... Work at a Single LevelTotal work at level j [ignoring work in recursive call

Trang 1

Master Method

Proof (Part 1)

Design and Analysis

of Algorithms I

Trang 2

The Master Method

Trang 3

Nextcore AI -Gopal Shangari

Assume : recurrence is

I

II

And n is a power of b

(general case is similar, but more tedious

ti

Idea : generalize MergeSort analysis

(i.e., use a recursion tree ti

( For some constant c ti

Trang 5

THE RECURSION TREE

Level 0

Level 1

.

.

.

.

Level logbn

a braches

Base cases (size 1ti

Trang 6

Work at a Single Level

Total work at level j [ignoring work in recursive calls]

Trang 7

Total Work

Summing over all levels j = 0,1,2,…, logbn :

Total

work

Trang 8

Nextcore AI -Gopal Shangari

Master Method Intui3on for

the 3 Cases

Design and Analysis

of Algorithms I

Trang 9

Nextcore AI -Gopal Shangari

HOW TO THINK ABOUT (*)

Interpreta3on

a = rate of subproblem prolifera3on (RSP)

bd = rate of work shrinkage (RWS)

(per subproblem)

Trang 10

Which of the following statements are true? (Check all that apply.ti

Trang 11

[might expect O(# leavesti]

Nextcore AI - Gopal Shangari

INTUITION FOR THE 3 CASES

1 RSP = RWS => Same amount of work each level (like

Merge

Sortti

[expect O(ndlog(nti]

2 RSP < RWS => less work each level => most work at the

O(ndti]

3 RSP > RWS => more work each level => most work at

the leaves

Trang 12

Master Method

Proof (Part II)

Design and Analysis

of Algorithms I

Trang 13

THE STORY SO FAR/CASE 1

Nextcore AI -Gopal Shangari

[ end Case 1 ]

=1

= (logbn + 1)

= 1 for all j

Trang 14

Basic Sums Fact

, we have

Proof : by induction (you check)

Upshot:

1 If r<1 is constant, RHS is <=

2 If r>1 is constant, RHS is <=

= a constant

Nextcore AI -Gopal Shangari

Trang 15

<= a constant ( independent of nti

[ by basic sums fact ]

[ total work dominated by top level ]

CASE 2

Nextcore AI -Gopal Shangari

:= r

Trang 16

Nextcore AI -Gopal Shangari

<= constant * largest term

:= r > 1

Trang 17

The number of levels of the recursion tree.

The number of nodes of the recursion tree.

The number of edges of the recursion tree.

Level 0

Level 1

Level logbn

# of leaves =

Trang 18

[End Case 3]

More intuiKve Simpler to apply

Trang 19

The Master Method

Ngày đăng: 17/11/2019, 07:35