Algorithms, Probability & Computing Emo Welzl Ueli Maurer - - PowerPoint PPT Presentation

algorithms probability computing
SMART_READER_LITE
LIVE PREVIEW

Algorithms, Probability & Computing Emo Welzl Ueli Maurer - - PowerPoint PPT Presentation

Algorithms, Probability & Computing Emo Welzl Ueli Maurer Angelika Steger Peter Widmayer Thomas Holenstein Contents Random(ized) Search Trees Point Location Network Flows Minimum Cut Randomized Algebraic Algorithms


slide-1
SLIDE 1

Algorithms, Probability & Computing

Emo Welzl Ueli Maurer Angelika Steger Peter Widmayer Thomas Holenstein

slide-2
SLIDE 2

Contents

  • Random(ized) Search Trees
  • Point Location
  • Network Flows
  • Minimum Cut
  • Randomized Algebraic Algorithms
  • Lovász Local Lemma
  • Cryptographic Reductions
  • Probabilistically Checkable Proofs
slide-3
SLIDE 3

Formalities

web page: http://www.ti.inf.ethz.ch/ew/courses/APC10/ exercise sessions (starting this week!): Wed 13-15, Wed 15-17, Fri 14-16 (choose any one) grade: final exam (60%): Sessionsprüfung, midterm exam (20%): November 15 (during class), two special assignments (20%): tba lecture notes: yes

slide-4
SLIDE 4

Part I: Data Structures

Randomized Search Trees

slide-5
SLIDE 5

Randomized Search Trees: Plan

  • Definition

 define an appropriate probability space

  • Study Properties

 learn methods and techniques how to do that

  • Revisit: Quicksort & Quickselect
  • A new data structure: Treaps
slide-6
SLIDE 6

Recall: (Binary) Search Tree

S some (totally ordered) set of elements/keys

BS search tree for S:

where

slide-7
SLIDE 7

Example

17 25 20 13 24 12 16 18 7 10 4 11 2 5 8 9

slide-8
SLIDE 8

Examples (2)

1 1 2 2 1

2 1 3 1 3 2 3 1 2 1 3 2 1 3 2

Note:

slide-9
SLIDE 9

Depth & Height

17 25 20 13 24 12 16 18 7 10 4 11 2 5 8 9

root: depth 0

 depth 1  depth 2  depth 3

height := max depth of an element

slide-10
SLIDE 10

Random Search Tree

random search tree for S:

u.a.r := uniformly at random ( = random with respect to uniform distribution)

slide-11
SLIDE 11

Example: S={1,2,3}

1 2 3 1 3 2 2 3 1 3 1 2 3 2 1 1/6 = 1/3 * 1/2 * 1 1/6 = 1/3 * 1/2 * 1 1/6 = 1/3 * 1/2 * 1 1/6 = 1/3 * 1/2 * 1 1/3 = 1/3 * 1 * 1

Note: This is not the uniform distribution on the set of all binary search trees for S = {1,2,3}

slide-12
SLIDE 12

Expected Number of Leaves

ln := E[ number of leaves in random search tree of size n]

l1 = 1 l2 = 1 l3 = ... 1 2 1 1 2

slide-13
SLIDE 13

Expected Number of Leaves

1 2 3 1 3 2 2 3 1 3 1 2 3 2 1 1/6 * 1 + 1/6 * 1 + 1/6 * 1 + 1/6 * 1 1/3 * 2 + = 4/3

l3 = ln := E[ number of leaves in random search tree for S = [n] ]

slide-14
SLIDE 14

Expected Number of Leaves

slide-15
SLIDE 15

Expected Number of Leaves

Hence, for n ≥ 3: Subtract both equations: I.e. Hence, (for n ≥ 3)

slide-16
SLIDE 16

Plan

Properties of Random Search Trees (Sec. 1.2 – 1.4)

  • number of leaves (warmup)
  • depth of keys:
  • sum of all depths
  • depth of smallest/largest key
  • depth of individual keys (ith smallest, for all 1 ≤ i ≤ n)
slide-17
SLIDE 17

Notations

slide-18
SLIDE 18

General Scheme

slide-19
SLIDE 19

Expected depth of smallest key

1 2 3 1 3 2 2 3 1 3 1 2 3 2 1 1/6 * 0 + 1/6 * 0 + 1/6 * 2 + 1/6 * 1 1/3 * 1 + = 5/6

d3 =

dn=E[Dn]: d1= 0, d2 = 1/2

slide-20
SLIDE 20

Bounds for harmonic number

1/x

slide-21
SLIDE 21

Bounds for harmonic number

1/x

slide-22
SLIDE 22

Expected overall depth

1 2 3 1 3 2 2 3 1 3 1 2 3 2 1 1/6 * (0+1+2) + 1/6 * (0+2+1) + 1/6 * (2+1+0) + 1/6 * (1+2+0) 1/3 * (1+0+1) + = 8/3

x3 =

slide-23
SLIDE 23

General Scheme

slide-24
SLIDE 24

Results

slide-25
SLIDE 25

Recap

Quicksort(S): For a set S of size n: Expected number of comparisons between elements of S = Expected overall depth in a random search tree for S = 2n ln(n) + O(n) Quickselect(S,k): For a set S of size n and any 1 ≤ k ≤ n Expected number of comparisons between elements of S ≤ 4n Note: best deterministic alg: 2.95n [Dor, Zwick 1999] lower bound: (2+ε)n [Dor, Zwick 2001] best randomized alg: 3/2 n [folklore]

slide-26
SLIDE 26

Recap (2)

(Randomized) Quicksort(S): for all inputs: Expected number of camparisons ≈ 2 n ln(n) (Deterministic) Quicksort(S): for random inputs: Expected number of camparisons ≈ 2 n ln(n)

slide-27
SLIDE 27

Today: Treaps

(Randomized) Treap(S): for all inputs: we can bound expected height, depth, etc (as above) (Deterministic) SearchTree(S): for random inputs: we can bound expected height, depth, etc

slide-28
SLIDE 28

Search Trees & Heaps

(Binary) Search Tree: for every node v: keys in left subtree < key(v) < keys in right subtree (Binary) Heap: for every node v: key(v) < keys in (both) subtrees

slide-29
SLIDE 29

Treap

More precisely: every node has two keys: for every node v:

  • 1st keys in left subtree < 1st key of v < 1st keys in right subtree
  • 2nd key of v < 2nd keys in (both) subtrees

Treap := Search Tree + Heap 1st key: the real key ... 2nd key: random values drawn u.a.r from [0,1)

Observe: A treap is a random search tree - for all inputs

slide-30
SLIDE 30

Rotations

y x

A B C

Note: 1st key: A < x < B < y < C 2nd key: before: everything ok except edge {x,y} now: everything ok x y

C B A

rotate

right subtree at y

rotate

left subtree at x

slide-31
SLIDE 31

Insertion

Insert element v into a treap T of size n:

  • choose 2nd key of v uar from [0,1)
  • insert v into search tree (as a leaf!)
  • rotate v upwards until heap property is satisfied

Runtime analysis:

  • time to insert v in search tree: O(ln n), as a random search tree has height O(ln n)
  • we will now show: E[ # of rotations] ≤ 2
slide-32
SLIDE 32

Expected number of rotations

Lemma: After inserting v we have: spine(v) = # of performed rotations Definitions:

  • left_spine(v) := number of nodes on path from v

to smallest element in subtree rooted at v

  • right_spine(v) := number of nodes on path from v

to largest element in subtree rooted at v

  • spine(v) := left_spine(right child of v) +

right_spine(left child of v) y x

A B C

left_spine(x) right_spine (root of B) spine(x) +

slide-33
SLIDE 33

Proof of Lemma

y v

A B C

v y

C B A

rotate spine(v) spine(v) Hence: every rotation increases spine(v) by exactly one ... qed.

slide-34
SLIDE 34

Expected number of rotations

Lemma: After inserting v we have: spine(v) = # of performed rotations spine(v) := left_spine(root of right subtree of v) + right_spine(root of left subtree of v) y x

A B C

spine(x) Lemma: In a random search tree of size n we have for all nodes v: