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

24 1 quick sort proof tủ tài liệu training pdf

16 49 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 16
Dung lượng 1,88 MB

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

Nội dung

Analysis I: A Decomp-osition Principle Design and Analysis of Algorithms I... Nextcore AI -Gopal Shangari... Nextcore AI -Gopal Shangari Preliminaries Fix input array A of length n Quic

Trang 1

Analysis I: A Decomp-osition Principle

Design and Analysis of

Algorithms I

Trang 2

Nextcore AI -Gopal Shangari

Trang 3

Nextcore AI -Gopal Shangari

Preliminaries

Fix input array A of length n

QuickSort (i.e., pivot sequencesti

Key Random Variable : for

= # of comparisons between two input elements made by

Remaining goal : E[C] =

O(nlog(ntiti

Lemma: running 8me of QuickSort dominated by comparisons

There exist constant c s.t for all

, (see

notesti

Trang 4

Nextcore AI -Gopal Shangari

Trang 5

0 or 1 0,

1, or 2

Te ve

Fix two elements of the input array How many 8mes can these

two elements get compared with each other during the execu8on

of QuickSort?

Reason : two elements compared only when one is the pivot, which is excluded from future recursive calls.

Thus : each Xij is an “indicator” (i.e., 0-‐1ti random variable

Trang 6

Nextcore AI -Gopal Shangari

Thus :

By Linearity of Expecta8on :

Since

Thus :

Trang 7

Nextcore AI -Gopal Shangari

1 Iden8fy random variable Y that you really care about

2 Express Y as sum of indicator random variables :

understand these!

Trang 8

Analysis II:

The Key Insight

Design and Analysis

of Algorithms I

Trang 9

Nextcore AI -Gopal Shangari

Trang 10

Nextcore AI -Gopal Shangari

Trang 11

Nextcore AI -Gopal Shangari

Trang 12

1 zi or zj gets chosen first => they get compared

Note : Since pivots always chosen uniformly at random, each of

2/(j ‐i+1ti

So :

Nextcore AI -Gopal Shangari

Choices that lead to case (1ti

Total # of choices

[S@ll need to show this is O(nlog(ntiti

Trang 13

Analysis III: Final

Calculations

Design and Analysis

of Algorithms I

Trang 14

Nextcore AI -Gopal Shangari

Trang 15

Nextcore AI -Gopal Shangari

<= n choices

for i

Note : for each fixed i, the inner sum is

Claim : this is <=

ln(nti

How big can this be ?

(*t i

Trang 16

Nextcore AI -Gopal Shangari

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

TỪ KHÓA LIÊN QUAN