via

INSERT: actual (1) amortized (1) O O X EXTRACT-MIN: actual (trees(H)+d(n)) amortized (d(n)) ? O O DECREASE-KEY: actual (# cuts) (marks(H)) amortized (1) ? O  O O

(H)=trees(H)+2 marks(H) ·

Lifecycle of a node

7 18 38 18 Consolidate

24 17 23 21 39 41

Loses second child 26 46 30 52 18 18

35 Loses first child

5.2: Fibonacci Heaps (Analysis) T.S. 3

5.2 Fibonacci Heaps (Analysis) Frank Stajano Thomas Sauerwald

Lent 2016 Outline

Recap of INSERT,EXTRACT-MIN and DECREASE-KEY

Glimpse at the Analysis

Amortized Analysis

Bounding the Maximum Degree

5.2: Fibonacci Heaps (Analysis) T.S. 2 and update min-pointer (if necessary)

Create a singleton Add to root list

21

Actual Costs: (1) min O

21

Fibonacci : INSERT

INSERT

21

17 24 23 7 3

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 13 and update min-pointer (if necessary)

Add to root list

21

Actual Costs: (1) min O

21

Fibonacci Heap: INSERT

INSERT Create a singleton tree

21

17 24 23 7 3

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 13 and update min-pointer (if necessary)

21

Actual Costs: (1) min O

Fibonacci Heap: INSERT

INSERT Create a singleton tree Add to root list

21

17 24 23 7 21 3

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 13 and update min-pointer (if necessary)

21

Actual Costs: (1) min O

Fibonacci Heap: INSERT

INSERT Create a singleton tree Add to root list

21

17 24 23 7 21 3

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 13 21

Actual Costs: (1) O

Fibonacci Heap: INSERT

INSERT Create a singleton tree Add to root list and update min-pointer (if necessary)

21

min

17 24 23 7 21 3

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 13 21

Fibonacci Heap: INSERT

INSERT Create a singleton tree Add to root list and update min-pointer (if necessary)

21

Actual Costs: (1) min O

17 24 23 7 21 3

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 13 + d(n)

X X (# children) X X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

41

44

Delete min Meld childen into root list and unmark them Consolidate so that no roots have the same degree Update minimum

degree 0 1 2 3 Actual Costs: min 1 degree=22 0 degree=00 1 0 1

17 18 52

17 24 23 41 39

23 26 46 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN

min

7 24 23 17 3

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 14 + d(n)

X (# children) X X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

41

44

X Meld childen into root list and unmark them Consolidate so that no roots have the same degree Update minimum

degree 0 1 2 3 Actual Costs: min 1 degree=22 0 degree=00 1 0 1

17 18 52

17 24 23 41 39

23 26 46 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min

min

7 24 23 17 3

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 14 + d(n)

X (# children) X X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

41

44

Meld childen into root list and unmark them Consolidate so that no roots have the same degree Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 18 52

17 24 23 41 39

23 26 46 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X

7 24 23 17 3

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 14 + d(n)

(# children) X X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

41

44

X Consolidate so that no roots have the same degree Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 183 52

17 24 23 41 39

23 26 46 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them

7 24 23 17

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 14 + d(n)

(# children) X X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

41

44

X Consolidate so that no roots have the same degree Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 183 52

17 24 23 41 39

23 26 46 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them

7 24 23 17

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 14 + d(n)

(# children) X X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

41

44

X Consolidate so that no roots have the same degree Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 183 52

17 24 23 41 39

23 26 46 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them

7 24 23 17

30 26 46 18 52 41

35 39 44

5.2: Fibonacci Heaps T.S. 14 + d(n)

(# children) X X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

Consolidate so that no roots have the same degree Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

(# children) X Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

degree 0 1 2 3 Actual Costs: min min 1 2 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree=2

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 0 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree=0

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

degree 0 1 2 3 Actual Costs: min min degree=2 degree=0

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

1 2 0 0 1 0 1

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

17 3

17 24 23 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 23 17 18 52 41

30 26 46 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

23 17 3

17 24 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 17 18 52 41

30 26 46 23 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

23 17 3

17 24 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 17 18 52 41

30 26 46 23 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

23 17 3

17 24 41 18 52 41

23 26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 17 18 52 41

30 26 46 23 39 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

23 17 17 3

24 23 41 18 52 41

26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 18 52 41

17 30 26 46 39 44

23 35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

23 17 17 3

24 23 41 18 52 41

26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 18 52 41

17 30 26 46 39 44

23 35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

23 17 17 3

24 23 41 18 52 41

26 46 44 39 44

35

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 24 18 52 41

17 30 26 46 39 44

23 35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3

26 46 23 41 18 52 41

35 44 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52 41

17 30 24 39 44

23 26 46

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3

26 46 23 41 18 52 41

35 44 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52 41

17 30 24 39 44

23 26 46

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3

26 46 23 41 18 52 41

35 44 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52 41

17 30 24 39 44

23 26 46

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3

26 46 23 41 18 52 41

35 44 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52 41

17 30 24 39 44

23 26 46

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3

26 46 23 41 18 52 41

35 44 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52 41

17 30 24 39 44

23 26 46

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3

26 46 23 41 18 52 41

35 44 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52 41

17 30 24 39 44

23 26 46

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3

26 46 23 41 18 52 41

35 44 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52 41

17 30 24 39 44

23 26 46

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3

26 46 23 41 18 52 41

35 44 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52 41

17 30 24 39 44

23 26 46

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3

26 46 23 41 18 52 41

35 44 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52 41

17 30 24 39 44

23 26 46

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3 41

26 46 23 18 52 41 44

35 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52

17 30 24 41 39

23 26 46 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3 41

26 46 23 18 52 41 44

35 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52

17 30 24 41 39

23 26 46 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3 41

26 46 23 18 52 41 44

35 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children)

degree 0 1 2 3

7 18 52

17 30 24 41 39

23 26 46 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

Update minimum

Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3 41

26 46 23 18 52 41 44

35 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children) X

degree 0 1 2 3

7 18 52

17 30 24 41 39

23 26 46 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

X

degree 0 1 2 3 Actual Costs: min min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3 41

26 46 23 18 52 41 44

35 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children) X Update minimum

7 18 52

17 30 24 41 39

23 26 46 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

(trees(H) ) O

degree 0 1 2 3 Actual Costs: min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3 41

26 46 23 18 52 41 44

35 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children) X Update minimum X

min

7 18 52

17 30 24 41 39

23 26 46 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

Every root becomes child of d(n) is the maximum degree of a another root at most once! degreeroot in any Fibonacci heap of size n 0 1 2 3 (trees(H) ) min 1 degree=22 0 O degree=00 1 0 1

24 23 17 17 3 41

26 46 23 18 52 41 44

35 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children) X Update minimum X

Actual Costs: min

7 18 52

17 30 24 41 39

23 26 46 44

35

5.2: Fibonacci Heaps T.S. 14 + d(n)

degree 0 1 2 3 (trees(H) ) min 1 degree=22 0 O degree=00 1 0 1

24 23 17 17 3 41

26 46 23 18 52 41 44

35 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children) X Update minimum X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

Actual Costs: min

7 18 52

17 30 24 41 39

23 26 46 44

35

5.2: Fibonacci Heaps T.S. 14 degree 0 1 2 3

min 1 degree=22 0 degree=00 1 0 1

24 23 17 17 3 41

26 46 23 18 52 41 44

35 39 44

Fibonacci Heap: EXTRACT-MIN

EXTRACT-MIN Delete min X Meld childen into root list and unmark them X Consolidate so that no roots have the same degree (# children) X Update minimum X Every root becomes child of d(n) is the maximum degree of a another root at most once! root in any Fibonacci heap of size n

Actual Costs: (trees(H) + d(n)) min O

7 18 52

17 30 24 41 39

23 26 46 44

35

5.2: Fibonacci Heaps T.S. 14 unmark and meld it into root list and recurse (Cascading Cut)

and:

If unmarked, mark it (unless it is a root) If marked,

(# cuts) O

X X

(Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list ⇒ Check if parent node is marked

Actual Cost: min

15 5 26 24

24 99 98

1.D ECREASE-KEY 46 15 15 2.D ECREASE-KEY 35 ; 5 15 ; 5 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer)

min

7 18 38

24 17 23 21 39 41

26 46 30 52

98 35 99

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

and:

If unmarked, mark it (unless it is a root) If marked,

(# cuts) O

X

Cut tree rooted at x, unmark x, meld into root list ⇒ Check if parent node is marked

Actual Cost: min

15 5 26 24

24 99 98

X 15 2.D ECREASE-KEY 35 5 15 ; 5 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated)

min

7 18 38

24 17 23 21 39 41

1.D ECREASE-KEY 46 15 26 46 30 52 ;

98 35 99

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

If unmarked, mark it (unless it is a root) If marked,

(# cuts) O

X

and: Check if parent node is marked

Actual Cost: min

15 5 26 24

24 99 98

X 15 2.D ECREASE-KEY 35 5 ; 5 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list ⇒

min

7 18 38

24 17 23 21 39 41

1.D ECREASE-KEY 46 15 26 46 30 52 ; 15 98 35 99

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

If unmarked, mark it (unless it is a root) If marked,

(# cuts) O

X

and: Check if parent node is marked

Actual Cost: min

15 5 26 24

24 99 98

X 46 2.D ECREASE-KEY 35 5 15 ; 5 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list ⇒

min

7 18 38

24 17 23 21 39 41

1.D ECREASE-KEY 46 15 26 15 30 52 ;

98 35 99

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

If unmarked, mark it (unless it is a root) If marked,

(# cuts) O

X

and: Check if parent node is marked

Actual Cost: min

15 5 26 24

24 99 98

X 46 2.D ECREASE-KEY 35 5 15 ; 5 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list ⇒

min

7 18 38

24 17 23 21 39 41

1.D ECREASE-KEY 46 15 26 15 30 52 ;

98 35 99

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

If unmarked, mark it (unless it is a root) If marked,

(# cuts) O

X

and: Check if parent node is marked

Actual Cost: min

15 5 26 24

24 99 98

X 46 2.D ECREASE-KEY 35 5 15 ; 5 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list ⇒

min

7 18 38

24 17 23 21 39 41

1.D ECREASE-KEY 46 15 26 15 30 52 ;

98 35 99

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

If unmarked, mark it (unless it is a root) If marked,

(# cuts) O

X

Check if parent node is marked

Actual Cost: min

5 26 24

24 98

X 46 2.D ECREASE-KEY 35 5 15 ; 5 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 26 15 30 52 ;

98 35

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

X

If unmarked, mark it (unless it is a root) If marked,

Actual Cost: min

5 26 24

24 98

X 46 2.D ECREASE-KEY 35 5 15 ; 5 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 26 15 30 52 ;

98 35

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

X

If marked,

Actual Cost: min

5 26 24

24 98

X 46 2.D ECREASE-KEY 35 5 15 ; 5 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root)

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 26 15 30 52 ;

98 35

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

X

If marked,

Actual Cost: min

5 26 24

98

X 46 2.D ECREASE-KEY 35 5 15 ; 5 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root)

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 26 15 30 52 ;

98 35

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

X

If marked,

Actual Cost: min

5 26 24

98

4615 2.D ECREASE-KEY 35 5 15 ; 5 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root)

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 X 26 30 52 ;

98 35

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

If marked,

Actual Cost: min

5 26 24

98

4615 15 X 5 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root)

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 35

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

If marked,

Actual Cost: min

5 26 24

98

4615 15 X 5 99

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root)

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 35 5

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

If marked,

Actual Cost: min

5 26 24

98

4615 15 X 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root)

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 355

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

If marked,

Actual Cost: min

5 26 24

98

4615 15 X 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root)

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 355

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

If marked,

Actual Cost: min

5 26 24

98

4615 15 X 35 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root)

min

7 18 38 15

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 5

5.2: Fibonacci Heaps T.S. 15 unmark and meld it into root list and recurse (Cascading Cut)

(# cuts) O

If marked,

Actual Cost: min

26 24

98

4615 15 X 35 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root)

min

7 18 38 15 5

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 5

5.2: Fibonacci Heaps T.S. 15 (# cuts) O

unmark and meld it into root list and recurse (Cascading Cut)

min Actual Cost:

26 24

98

4615 15 X 35 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked,

min

7 18 38 15 5

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 5

5.2: Fibonacci Heaps T.S. 15 (# cuts) O

min Actual Cost:

26 24

98

4615 15 X 35 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

min

7 18 38 15 5

24 17 23 21 39 41 99

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 5

5.2: Fibonacci Heaps T.S. 15 (# cuts) O

min Actual Cost:

24

4615 15 X 35 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

min

7 18 38 15 5 26

24 17 23 21 39 41 99 98

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 5

5.2: Fibonacci Heaps T.S. 15 (# cuts) O

min Actual Cost:

24

4615 15 X 35 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

min

7 18 38 15 5 26

24 17 23 21 39 41 99 98

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 5

5.2: Fibonacci Heaps T.S. 15 (# cuts) O

min Actual Cost:

24

4615 15 X 35 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

min

7 18 38 15 5 26

24 17 23 21 39 41 99 98

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 5

5.2: Fibonacci Heaps T.S. 15 (# cuts) O

min Actual Cost:

4615 15 X 35 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

min

7 18 38 15 5 26 24

24 17 23 21 39 41 99 98

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 5

5.2: Fibonacci Heaps T.S. 15 (# cuts) O

min Actual Cost:

4615 15 X 35 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

min

7 18 38 15 5 26 24

24 17 23 21 39 41 99 98

1.D ECREASE-KEY 46 15 X 26 30 52 2.D ECREASE-KEY 35 ; 5 ; 98 5

5.2: Fibonacci Heaps T.S. 15 (# cuts) O

min Actual Cost:

24

26 4615 15 X 98 355 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

min

7 18 38 15 5 26 24

17 23 21 39 41 99 98

1.D ECREASE-KEY 46 15 X 30 52 2.D ECREASE-KEY 35 ; 5 ;

5.2: Fibonacci Heaps T.S. 15 (# cuts) O

min Actual Cost:

24

26 4615 15 98 355 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

min

7 18 38 15 5 26 24

17 23 21 39 41 99 98

1.D ECREASE-KEY 46 15 X 30 52 2.D ECREASE-KEY 35 ; 5 X ;

5.2: Fibonacci Heaps T.S. 15 min (# cuts) O

24

26 4615 15 98 355 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

Actual Cost: min

7 18 38 15 5 26 24

17 23 21 39 41 99 98

1.D ECREASE-KEY 46 15 X 30 52 2.D ECREASE-KEY 35 ; 5 X ;

5.2: Fibonacci Heaps T.S. 15 min

24

26 4615 15 98 355 99 5

Fibonacci Heap: DECREASE-KEY

DECREASE-KEY of node x Decrease the key of x (given by a pointer) (Here we consider only cases where heap-order is violated) Cut tree rooted at x, unmark x, meld into root list and: ⇒ Check if parent node is marked If unmarked, mark it (unless it is a root) If marked, unmark and meld it into root list and recurse (Cascading Cut)

Actual Cost: (# cuts) min O

7 18 38 15 5 26 24

17 23 21 39 41 99 98

1.D ECREASE-KEY 46 15 X 30 52 2.D ECREASE-KEY 35 ; 5 X ;

5.2: Fibonacci Heaps T.S. 15 Outline

Recap of INSERT,EXTRACT-MIN and DECREASE-KEY

Glimpse at the Analysis

Amortized Analysis

Bounding the Maximum Degree

5.2: Fibonacci Heaps (Analysis) T.S. 2 Lifecycle of a node

18 Consolidate

Loses second child

18 18

Loses first child

amortized (1) O X amortized (d(n)) ? O amortized (1) ? O

Φ(H) = trees(H)+2 marks(H) ·

7 18 38

24 17 23 21 39 41

26 46 30 52

35

Amortized Analysis via Potential Method

INSERT: actual (1) O EXTRACT-MIN: actual (trees(H) + d(n)) O DECREASE-KEY: actual (# cuts) (marks(H)) O ≤ O

5.2: Fibonacci Heaps (Analysis) T.S. 3 Lifecycle of a node

18 Consolidate

Loses second child

18 18

Loses first child

amortized (1) O X amortized (d(n)) ? O amortized (1) ? O

7 18 38

24 17 23 21 39 41

26 46 30 52

35

Amortized Analysis via Potential Method

INSERT: actual (1) O EXTRACT-MIN: actual (trees(H) + d(n)) O DECREASE-KEY: actual (# cuts) (marks(H)) O ≤ O

Φ(H) = trees(H)+2 marks(H) ·

5.2: Fibonacci Heaps (Analysis) T.S. 3 amortized (1) O X amortized (d(n)) ? O amortized (1) ? O

Lifecycle of a node

18 Consolidate

Loses second child

18 18

Loses first child

Amortized Analysis via Potential Method

INSERT: actual (1) O EXTRACT-MIN: actual (trees(H) + d(n)) O DECREASE-KEY: actual (# cuts) (marks(H)) O ≤ O

Φ(H) = trees(H)+2 marks(H) ·

7 18 38

24 17 23 21 39 41

26 46 30 52

35

5.2: Fibonacci Heaps (Analysis) T.S. 3 amortized (1) O X amortized (d(n)) ? O amortized (1) ? O

Lifecycle of a node

18 Consolidate

Loses second child

18 18

Loses first child

Amortized Analysis via Potential Method

INSERT: actual (1) O EXTRACT-MIN: actual (trees(H) + d(n)) O DECREASE-KEY: actual (# cuts) (marks(H)) O ≤ O

Φ(H) = trees(H)+2 marks(H) ·

7 18 38

24 17 23 21 39 41

26 46 30 52

35

5.2: Fibonacci Heaps (Analysis) T.S. 3 amortized (1) O X amortized (d(n)) ? O amortized (1) ? O

Lifecycle of a node

18 Consolidate

Loses second child

18 18

Loses first child

Amortized Analysis via Potential Method

INSERT: actual (1) O EXTRACT-MIN: actual (trees(H) + d(n)) O DECREASE-KEY: actual (# cuts) (marks(H)) O ≤ O

Φ(H) = trees(H)+2 marks(H) ·

7 18 38

24 17 23 21 39 41

26 46 30 52

35

5.2: Fibonacci Heaps (Analysis) T.S. 3 X ? ?

Amortized Analysis via Potential Method

INSERT: actual (1) amortized (1) O O EXTRACT-MIN: actual (trees(H) + d(n)) amortized (d(n)) O O DECREASE-KEY: actual (# cuts) (marks(H)) amortized (1) O ≤ O O

Φ(H) = trees(H)+2 marks(H) ·

Lifecycle of a node

7 18 38 18 Consolidate

24 17 23 21 39 41

Loses second child 26 46 30 52 18 18

35 Loses first child

5.2: Fibonacci Heaps (Analysis) T.S. 3 Amortized Analysis via Potential Method

INSERT: actual (1) amortized (1) O O X EXTRACT-MIN: actual (trees(H) + d(n)) amortized (d(n)) ? O O DECREASE-KEY: actual (# cuts) (marks(H)) amortized (1) ? O ≤ O O

Φ(H) = trees(H)+2 marks(H) ·

Lifecycle of a node

7 18 38 18 Consolidate

24 17 23 21 39 41

Loses second child 26 46 30 52 18 18

35 Loses first child

5.2: Fibonacci Heaps (Analysis) T.S. 3 Outline

Recap of INSERT,EXTRACT-MIN and DECREASE-KEY

Glimpse at the Analysis

Amortized Analysis

Bounding the Maximum Degree

5.2: Fibonacci Heaps (Analysis) T.S. 4 trees(H) + x marks(H) x + 2 −

7 18

24 17 23 21 39 trees(H0) = marks(H0) ≤ 26 30 35 ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − − 52 5

(x + 1) + 4 x = (1) ≤ O − O

Φ(H) = trees(H) + 2 marks(H) · First Coin pays cut Second Coin; increase of trees(H) ; Change in Potential

Scale up potential units Amortized Cost

eci = ci + ∆Φ

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

5.2: Fibonacci Heaps (Analysis) T.S. 5 trees(H) + x marks(H) x + 2 −

7 18

24 17 23 21 39 trees(H0) = marks(H0) ≤ 26 30 35 ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − − 52 5

(x + 1) + 4 x = (1) ≤ O − O

First Coin pays cut Second Coin; increase of trees(H) ; Change in Potential

Scale up potential units Amortized Cost

eci = ci + ∆Φ

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

5.2: Fibonacci Heaps (Analysis) T.S. 5 trees(H) + x marks(H) x + 2 −

(x + 1) + 4 x = (1) ≤ O − O

First Coin pays cut Second Coin; increase of trees(H) ;

trees(H0) = marks(H0) ≤ ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − −

Scale up potential units Amortized Cost

eci = ci + ∆Φ

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

7 18 Change in Potential 24 17 23 21 39

26 30 35

52 5

5.2: Fibonacci Heaps (Analysis) T.S. 5 marks(H) x + 2 −

(x + 1) + 4 x = (1) ≤ O − O

First Coin pays cut Second Coin; increase of trees(H) ;

trees(H) + x marks(H0) ≤ ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − −

Scale up potential units Amortized Cost

eci = ci + ∆Φ

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

7 18 Change in Potential 24 17 23 21 39 trees(H0) =

26 30 35

52 5

5.2: Fibonacci Heaps (Analysis) T.S. 5 marks(H) x + 2 −

(x + 1) + 4 x = (1) ≤ O − O

First Coin pays cut Second Coin; increase of trees(H) ;

marks(H0) ≤ ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − −

Scale up potential units Amortized Cost

eci = ci + ∆Φ

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

7 18 Change in Potential 24 17 23 21 39 trees(H0) = trees(H) + x

26 30 35

52 5

5.2: Fibonacci Heaps (Analysis) T.S. 5 (x + 1) + 4 x = (1) ≤ O − O

First Coin pays cut Second Coin; increase of trees(H) ;

marks(H) x + 2 − ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − −

Scale up potential units Amortized Cost

eci = ci + ∆Φ

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

7 18 Change in Potential 24 17 23 21 39 trees(H0) = trees(H) + x marks(H0) ≤ 26 30 35

52 5

5.2: Fibonacci Heaps (Analysis) T.S. 5 (x + 1) + 4 x = (1) ≤ O − O

First Coin pays cut Second Coin; increase of trees(H) ;

∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − −

Scale up potential units Amortized Cost

eci = ci + ∆Φ

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

7 18 Change in Potential 24 17 23 21 39 trees(H0) = trees(H) + x marks(H0) marks(H) x + 2 ≤ − 26 30 35

52 5

5.2: Fibonacci Heaps (Analysis) T.S. 5 (x + 1) + 4 x = (1) ≤ O − O

First Coin pays cut Second Coin; increase of trees(H) ;

Scale up potential units Amortized Cost

eci = ci + ∆Φ

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

7 18 Change in Potential 24 17 23 21 39 trees(H0) = trees(H) + x marks(H0) marks(H) x + 2 ≤ − 26 30 35 ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − − 52 5

5.2: Fibonacci Heaps (Analysis) T.S. 5 First Coin pays cut Second Coin; increase of trees(H) ;

Scale up potential units

(x + 1) + 4 x = (1) ≤ O − O

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

7 18 Change in Potential 24 17 23 21 39 trees(H0) = trees(H) + x marks(H0) marks(H) x + 2 ≤ − 26 30 35 ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − − 52 5 Amortized Cost

eci = ci + ∆Φ

5.2: Fibonacci Heaps (Analysis) T.S. 5 First Coin pays cut Second Coin; increase of trees(H) ;

= (1) O

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

7 18 Change in Potential 24 17 23 21 39 trees(H0) = trees(H) + x marks(H0) marks(H) x + 2 ≤ − 26 30 35 ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − − 52 5 Scale up potential units Amortized Cost c = c + ∆Φ (x + 1) + 4 x ei i ≤ O −

5.2: Fibonacci Heaps (Analysis) T.S. 5 First Coin pays cut Second Coin; increase of trees(H) ;

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) ·

7 18 Change in Potential 24 17 23 21 39 trees(H0) = trees(H) + x marks(H0) marks(H) x + 2 ≤ − 26 30 35 ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − − 52 5 Scale up potential units Amortized Cost c = c + ∆Φ (x + 1) + 4 x = (1) ei i ≤ O − O

5.2: Fibonacci Heaps (Analysis) T.S. 5 Scale up potential units

Amortized Analysis of DECREASE-KEY

Actual Cost DECREASE-KEY: (x + 1), where x is the number of cuts. O

Φ(H) = trees(H) + 2 marks(H) · First Coin pays cut Second Coin; increase of trees(H) ; 7 18 Change in Potential 24 17 23 21 39 trees(H0) = trees(H) + x marks(H0) marks(H) x + 2 ≤ − 26 30 35 ∆Φ x + 2 ( x + 2) = 4 x. ⇒ ≤ · − − 52 5 Amortized Cost c = c + ∆Φ (x + 1) + 4 x = (1) ei i ≤ O − O

5.2: Fibonacci Heaps (Analysis) T.S. 5 trees(H0) d(n) + 1 ≤

min degrees 0 1 2 3 d(n) marks(H0) marks(H) 183 52 41

1839 52 4144 ∆Φ d(n) + 1 trees(H) ⇒ ≤ − 39 44

(trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

Φ(H) = trees(H) + 2 marks(H) ·

Change in Potential

Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

5.2: Fibonacci Heaps (Analysis) T.S. 6 trees(H0) d(n) + 1 ≤

min degrees 0 1 2 3 d(n) marks(H0) marks(H) 183 52 41

1839 52 4144 ∆Φ d(n) + 1 trees(H) ⇒ ≤ − 39 44

(trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

Change in Potential

Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

5.2: Fibonacci Heaps (Analysis) T.S. 6 trees(H0) d(n) + 1 ≤

(trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

min degrees 0 1 2 3 d(n) marks(H0) marks(H) 183 52 41

1839 52 4144 ∆Φ d(n) + 1 trees(H) ⇒ ≤ − 39 44 Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

Change in Potential

5.2: Fibonacci Heaps (Analysis) T.S. 6 trees(H0) d(n) + 1 ≤

(trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

degrees 0 1 2 3 d(n) 18 52 41

39 44 ∆Φ d(n) + 1 trees(H) ⇒ ≤ −

Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) · min Change in Potential marks(H0) ? marks(H) 3

18 52 41

39 44

5.2: Fibonacci Heaps (Analysis) T.S. 6 trees(H0) d(n) + 1 ≤

(trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

min degrees 0 1 2 3 d(n) 3

18 52 41 ∆Φ d(n) + 1 trees(H) ⇒ ≤ − 39 44 Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

Change in Potential marks(H0) ? marks(H) 18 52 41

39 44

5.2: Fibonacci Heaps (Analysis) T.S. 6 trees(H0) d(n) + 1 ≤

(trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

min degrees 0 1 2 3 d(n) 3

18 52 41 ∆Φ d(n) + 1 trees(H) ⇒ ≤ − 39 44 Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

Change in Potential marks(H0) marks(H) 18 52 41 ≤

39 44

5.2: Fibonacci Heaps (Analysis) T.S. 6 (trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

min

183 52 41 d(n) + 1 1839 52 4144 ∆Φ d(n) + 1 trees(H) ⇒ ≤ − 39 44 Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

degrees Change in Potential 0 1 2 3 d(n) marks(H0) marks(H) ≤ trees(H0) ≤

5.2: Fibonacci Heaps (Analysis) T.S. 6 (trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

min

183 52 41 d(n) + 1 1839 52 4144 ∆Φ d(n) + 1 trees(H) ⇒ ≤ − 39 44 Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

degrees Change in Potential 0 1 2 3 d(n) marks(H0) marks(H) ≤ trees(H0) ≤

5.2: Fibonacci Heaps (Analysis) T.S. 6 (trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

min

183 52 41

1839 52 4144 ∆Φ d(n) + 1 trees(H) ⇒ ≤ − 39 44 Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

degrees Change in Potential 0 1 2 3 d(n) marks(H0) marks(H) ≤ trees(H0) d(n) + 1 ≤

5.2: Fibonacci Heaps (Analysis) T.S. 6 (trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O

min

183 52 41

1839 52 4144

39 44 Amortized Cost

eci = ci + ∆Φ

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

degrees Change in Potential 0 1 2 3 d(n) marks(H0) marks(H) ≤ trees(H0) d(n) + 1 ≤ ∆Φ d(n) + 1 trees(H) ⇒ ≤ −

5.2: Fibonacci Heaps (Analysis) T.S. 6 min

183 52 41

1839 52 4144

39 44

(trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ≤ O − O How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

degrees Change in Potential 0 1 2 3 d(n) marks(H0) marks(H) ≤ trees(H0) d(n) + 1 ≤ ∆Φ d(n) + 1 trees(H) ⇒ ≤ −

Amortized Cost

eci = ci + ∆Φ

5.2: Fibonacci Heaps (Analysis) T.S. 6 min

183 52 41

1839 52 4144

39 44

= (d(n)) O How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

degrees Change in Potential 0 1 2 3 d(n) marks(H0) marks(H) ≤ trees(H0) d(n) + 1 ≤ ∆Φ d(n) + 1 trees(H) ⇒ ≤ −

Amortized Cost c = c + ∆Φ (trees(H) +d(n)) + d(n) + 1 trees(H) ei i ≤ O −

5.2: Fibonacci Heaps (Analysis) T.S. 6 min

183 52 41

1839 52 4144

39 44

How to bound d(n)?

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

degrees Change in Potential 0 1 2 3 d(n) marks(H0) marks(H) ≤ trees(H0) d(n) + 1 ≤ ∆Φ d(n) + 1 trees(H) ⇒ ≤ −

Amortized Cost c = c + ∆Φ (trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ei i ≤ O − O

5.2: Fibonacci Heaps (Analysis) T.S. 6 min

183 52 41

1839 52 4144

39 44

Amortized Analysis of EXTRACT-MIN

Actual Cost EXTRACT-MIN: (trees(H) + d(n)) O

Φ(H) = trees(H) + 2 marks(H) ·

degrees Change in Potential 0 1 2 3 d(n) marks(H0) marks(H) ≤ trees(H0) d(n) + 1 ≤ ∆Φ d(n) + 1 trees(H) ⇒ ≤ −

Amortized Cost c = c + ∆Φ (trees(H) +d(n)) + d(n) + 1 trees(H) = (d(n)) ei i ≤ O − O How to bound d(n)?

5.2: Fibonacci Heaps (Analysis) T.S. 6 Outline

Recap of INSERT,EXTRACT-MIN and DECREASE-KEY

Glimpse at the Analysis

Amortized Analysis

Bounding the Maximum Degree

5.2: Fibonacci Heaps (Analysis) T.S. 7 d = 3, n = 23

Fibonacci Heap Not all trees are binomial trees, but still d(n) log n, where ϕ 1.62. ≤ ϕ ≈

Skip Analysis

Bounding the Maximum Degree

Binomial Heap Every tree is a binomial tree d(n) log n. ⇒ ≤ 2

5.2: Fibonacci Heaps (Analysis) T.S. 8 d = 3, n = 23

Fibonacci Heap Not all trees are binomial trees, but still d(n) log n, where ϕ 1.62. ≤ ϕ ≈

Skip Analysis

Bounding the Maximum Degree

Binomial Heap Every tree is a binomial tree d(n) log n. ⇒ ≤ 2

5.2: Fibonacci Heaps (Analysis) T.S. 8 Fibonacci Heap Not all trees are binomial trees, but still d(n) log n, where ϕ 1.62. ≤ ϕ ≈

Skip Analysis

Bounding the Maximum Degree

Binomial Heap Every tree is a binomial tree d(n) log n. ⇒ ≤ 2

d = 3, n = 23

5.2: Fibonacci Heaps (Analysis) T.S. 8 d = 3, n = 23

Fibonacci Heap Not all trees are binomial trees, but still d(n) log n, where ϕ 1.62. ≤ ϕ ≈

Skip Analysis

Bounding the Maximum Degree

Binomial Heap Every tree is a binomial tree d(n) log n. ⇒ ≤ 2

5.2: Fibonacci Heaps (Analysis) T.S. 8 d = 3, n = 23

Skip Analysis

Bounding the Maximum Degree

Binomial Heap Every tree is a binomial tree d(n) log n. ⇒ ≤ 2

Fibonacci Heap Not all trees are binomial trees, but still d(n) log n, where ϕ 1.62. ≤ ϕ ≈

5.2: Fibonacci Heaps (Analysis) T.S. 8 d = 3, n = 23

Bounding the Maximum Degree

Binomial Heap Every tree is a binomial tree d(n) log n. ⇒ ≤ 2

Fibonacci Heap Not all trees are binomial trees, but still d(n) log n, where ϕ 1.62. ≤ ϕ ≈

Skip Analysis

5.2: Fibonacci Heaps (Analysis) T.S. 8 and d1, d2,..., dk be their degrees

y1 y2 y3 ? y4 yk

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

x

Lower Bounding Degrees of Children

d(n) log n ≤ ϕ

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees

y1 y2 y3 ? y4 yk

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

x

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees

y1 y2 y3 ? y4 yk

Let y1, y2,..., yk be the children in the order of attachment

1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

x

y1 y2 y3 y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 ? y4

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 ? y4

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 ? y4

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment and d1, d2,..., dk be their degrees

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 y1 y2 y3 ? y4 yk

Lower Bounding Degrees of Children

We will prove a stronger statement: Any tree with degree k contains at least ϕk nodes.

d(n) log n ≤ ϕ

Consider any node x of degree k (not necessarily a root) at the final state

Let y1, y2,..., yk be the children in the order of attachment and d1, d2,..., dk be their degrees 1 i k : d i 2 ⇒∀ ≤ ≤ i ≥ −

x

y1 y2 y3 y4 yk

5.2: Fibonacci Heaps (Analysis) T.S. 9 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

N(0) = 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 = 5 + 3

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

5.2: Fibonacci Heaps (Analysis) T.S. 10 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

N(0) = 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

5.2: Fibonacci Heaps (Analysis) T.S. 10 3 4 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

= 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 = 5 + 3 0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0)

5.2: Fibonacci Heaps (Analysis) T.S. 10 3 4 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

= 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0)

0

5.2: Fibonacci Heaps (Analysis) T.S. 10 3 4 2 0 0 0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

= 1 = 2 N(2) = 3 N(3) = 5 N(4) = 8 = 5 + 3 1 0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1)

0

5.2: Fibonacci Heaps (Analysis) T.S. 10 3 4 2 0 0 0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

= 1 = 2 N(2) = 3 N(3) = 5 N(4) = 8 = 5 + 3

0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1)

0 1

5.2: Fibonacci Heaps (Analysis) T.S. 10 3 4 2 0 0 0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

= 1 = 2 N(2) = 3 N(3) = 5 N(4) = 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1)

0 1 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 3 4

0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

= 1 = 2 = 3 N(3) = 5 N(4) = 8 = 5 + 3 2 0 0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2)

0 1 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 3 4

0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

= 1 = 2 = 3 N(3) = 5 N(4) = 8 = 5 + 3

0 0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2)

0 1 2 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 3 4

0 0 1 0 0 1 2 0 0 0 0

N(k) = F(k + 2)?

= 1 = 2 = 3 N(3) = 5 N(4) = 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2)

0 1 2 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 4

0 0 1 2 0 0 0

N(k) = F(k + 2)?

= 1 = 2 = 3 = 5 N(4) = 8 = 5 + 3 3

0 0 1 0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2) N(3)

0 1 2 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 4

0 0 1 2 0 0 0

N(k) = F(k + 2)?

= 1 = 2 = 3 = 5 N(4) = 8 = 5 + 3

0 0 1 0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2) N(3) 3 0 1 2 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 4

0 0 1 2 0 0 0

N(k) = F(k + 2)?

= 1 = 2 = 3 = 5 N(4) = 8 = 5 + 3

0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2) N(3) 3 0 1 2 0 0 0 0 0 1

5.2: Fibonacci Heaps (Analysis) T.S. 10 4

0 0 1 2 0 0 0

N(k) = F(k + 2)?

= 1 = 2 = 3 = 5 N(4) = 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2) N(3) 3 0 1 2 0 0 0 0 0 1 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 1 = 2 = 3 = 5 = 8 = 5 + 3 4

0 0 1 2 0 0 0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2) N(3) N(4) 3 0 1 2 0 0 0 0 0 1 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 1 = 2 = 3 = 5 = 8 = 5 + 3

0 0 1 2 0 0 0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2) N(3) N(4) 3 4 0 1 2 0 0 0 0 0 1 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 1 = 2 = 3 = 5 = 8 = 5 + 3

0 0 0

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2) N(3) N(4) 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 1 = 2 = 3 = 5 = 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) N(1) N(2) N(3) N(4) 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 2 = 3 = 5 = 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) = 1 N(1) N(2) N(3) N(4) 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 3 = 5 = 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) = 1 N(1) = 2 N(2) N(3) N(4) 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 5 = 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) = 1 N(1) = 2 N(2) = 3 N(3) N(4) 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 8 = 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) = 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) = 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) = 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) = 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

= 5 + 3

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) = 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 N(k) = F(k + 2)?

From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k.

N(0) = 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 = 5 + 3 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 From Degrees to Minimum Subtree Sizes

x

y1 y2 y3 y4 yk

1 i k : d i 2 ∀ ≤ ≤ i ≥ −

Definition Let N(k) be the minimum possible number of nodes of a subtree rooted at a node of degree k. N(k) = F(k + 2)?

N(0) = 1 N(1) = 2 N(2) = 3 N(3) = 5 N(4) = 8 = 5 + 3 3 4 0 1 2 0 0 0 0 0 1 0 0 1 2 0 0 0 0

5.2: Fibonacci Heaps (Analysis) T.S. 10 1

N(k) =

1 N(2 2) N(3 2) N(k 2) − − −

N(k) = 1 + 1 + N(2 2) + N(3 2) + + N(k 2) − − ··· − k−2 X = 1 + 1 + N(`) `=0 k−3 X = 1 + 1 + N(`) + N(k 2) − `=0 = N(k 1) + N(k 2) − − = F(k + 1) + F(k) = F(k + 2)

From Minimum Subtree Sizes to Fibonacci Numbers

1 i k : di i 2 N(k) = F(k + 2)? ∀ ≤ ≤ ≥ −

5.2: Fibonacci Heaps (Analysis) T.S. 11 N(k) = 1 + 1 + N(2 2) + N(3 2) + + N(k 2) − − ··· − k−2 X = 1 + 1 + N(`) `=0 k−3 X = 1 + 1 + N(`) + N(k 2) − `=0 = N(k 1) + N(k 2) − − = F(k + 1) + F(k) = F(k + 2)

From Minimum Subtree Sizes to Fibonacci Numbers

1 i k : di i 2 N(k) = F(k + 2)? ∀ ≤ ≤ ≥ −

1

N(k) =

1 N(2 2) N(3 2) N(k 2) − − −

5.2: Fibonacci Heaps (Analysis) T.S. 11 From Minimum Subtree Sizes to Fibonacci Numbers

1 i k : di i 2 N(k) = F(k + 2)? ∀ ≤ ≤ ≥ −

1

N(k) =

1 N(2 2) N(3 2) N(k 2) − − −

N(k) = 1 + 1 + N(2 2) + N(3 2) + + N(k 2) − − ··· − k−2 X = 1 + 1 + N(`) `=0 k−3 X = 1 + 1 + N(`) + N(k 2) − `=0 = N(k 1) + N(k 2) − − = F(k + 1) + F(k) = F(k + 2)

5.2: Fibonacci Heaps (Analysis) T.S. 11 X X

F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

Base k = 0: F(2) = 1 and ϕ0 = 1 Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ Inductive Step (k 2): ≥ F(k + 2) =

ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k:

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 ....

5.2: Fibonacci Heaps (Analysis) T.S. 12 X X

F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

Base k = 0: F(2) = 1 and ϕ0 = 1 Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ Inductive Step (k 2): ≥ F(k + 2) =

Proof by induction on k:

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

5.2: Fibonacci Heaps (Analysis) T.S. 12 X X

F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

Base k = 0: F(2) = 1 and ϕ0 = 1 Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ Inductive Step (k 2): ≥ F(k + 2) =

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k:

5.2: Fibonacci Heaps (Analysis) T.S. 12 X

F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

X Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ Inductive Step (k 2): ≥ F(k + 2) =

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: Base k = 0: F(2) = 1 and ϕ0 = 1

5.2: Fibonacci Heaps (Analysis) T.S. 12 X

F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ Inductive Step (k 2): ≥ F(k + 2) =

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: 0 Base k = 0: F(2) = 1 and ϕ = 1 X

5.2: Fibonacci Heaps (Analysis) T.S. 12 F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

X Inductive Step (k 2): ≥ F(k + 2) =

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: 0 Base k = 0: F(2) = 1 and ϕ = 1 X Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈

5.2: Fibonacci Heaps (Analysis) T.S. 12 F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

Inductive Step (k 2): ≥ F(k + 2) =

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: 0 Base k = 0: F(2) = 1 and ϕ = 1 X Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ X

5.2: Fibonacci Heaps (Analysis) T.S. 12 F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: 0 Base k = 0: F(2) = 1 and ϕ = 1 X Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ X Inductive Step (k 2): ≥ F(k + 2) =

5.2: Fibonacci Heaps (Analysis) T.S. 12 ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: 0 Base k = 0: F(2) = 1 and ϕ = 1 X Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ X Inductive Step (k 2): ≥ F(k + 2) = F(k + 1) + F(k)

5.2: Fibonacci Heaps (Analysis) T.S. 12 = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: 0 Base k = 0: F(2) = 1 and ϕ = 1 X Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ X Inductive Step (k 2): ≥ F(k + 2) = F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥

5.2: Fibonacci Heaps (Analysis) T.S. 12 = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: 0 Base k = 0: F(2) = 1 and ϕ = 1 X Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ X Inductive Step (k 2): ≥ F(k + 2) = F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) ·

5.2: Fibonacci Heaps (Analysis) T.S. 12 = ϕk

Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: 0 Base k = 0: F(2) = 1 and ϕ = 1 X Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ X Inductive Step (k 2): ≥ F(k + 2) = F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) ·

5.2: Fibonacci Heaps (Analysis) T.S. 12 Exponential Growth of Fibonacci Numbers

Lemma 19.3 For all integers k 0, the (k + 2)nd Fib. number satisfies F(k + 2) ϕk , ≥ ≥ where ϕ = (1 + √5)/2 = 1.61803 .... ϕ2 = ϕ + 1 Fibonacci Numbers grow at least exponentially fast in k.

Proof by induction on k: 0 Base k = 0: F(2) = 1 and ϕ = 1 X Base k = 1: F(3) = 2 and ϕ1 1.619 < 2 ≈ X Inductive Step (k 2): ≥ F(k + 2) = F(k + 1) + F(k) ϕk−1 + ϕk−2 (by the inductive hypothesis) ≥ = ϕk−2 (ϕ + 1) · = ϕk−2 ϕ2 (ϕ2 = ϕ + 1) · = ϕk

5.2: Fibonacci Heaps (Analysis) T.S. 12 log n k ϕ ≥

n = F(k + 2) ϕk ≥ ≥ ⇒

N(k)

Putting the Pieces Together

Amortized Analysis INSERT: amortized cost (1) O EXTRACT-MIN: amortized cost (d(n)) O DECREASE-KEY: amortized cost (1) O

5.2: Fibonacci Heaps (Analysis) T.S. 13 log n k ϕ ≥

n = F(k + 2) ϕk ≥ ≥ ⇒

Putting the Pieces Together

Amortized Analysis INSERT: amortized cost (1) O EXTRACT-MIN: amortized cost (d(n)) O DECREASE-KEY: amortized cost (1) O

N(k)

5.2: Fibonacci Heaps (Analysis) T.S. 13 log n k ϕ ≥

n ϕk ≥ ≥ ⇒

Putting the Pieces Together

Amortized Analysis INSERT: amortized cost (1) O EXTRACT-MIN: amortized cost (d(n)) O DECREASE-KEY: amortized cost (1) O

N(k) = F(k + 2)

5.2: Fibonacci Heaps (Analysis) T.S. 13 log n k ϕ ≥

n ≥ ⇒

Putting the Pieces Together

Amortized Analysis INSERT: amortized cost (1) O EXTRACT-MIN: amortized cost (d(n)) O DECREASE-KEY: amortized cost (1) O

N(k) = F(k + 2) ϕk ≥

5.2: Fibonacci Heaps (Analysis) T.S. 13 log n k ϕ ≥

Putting the Pieces Together

Amortized Analysis INSERT: amortized cost (1) O EXTRACT-MIN: amortized cost (d(n)) O DECREASE-KEY: amortized cost (1) O

n N(k) = F(k + 2) ϕk ≥ ≥

5.2: Fibonacci Heaps (Analysis) T.S. 13 Putting the Pieces Together

Amortized Analysis INSERT: amortized cost (1) O EXTRACT-MIN: amortized cost (d(n)) O DECREASE-KEY: amortized cost (1) O

n N(k) = F(k + 2) ϕk ≥ ≥ log n k ⇒ ϕ ≥

5.2: Fibonacci Heaps (Analysis) T.S. 13 Putting the Pieces Together

Amortized Analysis INSERT: amortized cost (1) O X EXTRACT-MIN: amortized cost X(dX(nX)) (log n) O X O DECREASE-KEY: amortized cost (1) O

n N(k) = F(k + 2) ϕk ≥ ≥ log n k ⇒ ϕ ≥

5.2: Fibonacci Heaps (Analysis) T.S. 13 amortized (1) O amortized (d(n)) = (log n) O 6 O amortized (1) O

Φ(H) = trees(H)

7 18 38

24 17 23 21 39 41

26 46 30 52

35

What if we don’t have marked nodes?

INSERT: actual (1) O EXTRACT-MIN: actual (trees(H) + d(n)) O DECREASE-KEY: actual (1) O

5.2: Fibonacci Heaps (Analysis) T.S. 14 amortized (1) O amortized (d(n)) = (log n) O 6 O amortized (1) O

7 18 38

24 17 23 21 39 41

26 46 30 52

35

What if we don’t have marked nodes?

INSERT: actual (1) O EXTRACT-MIN: actual (trees(H) + d(n)) O DECREASE-KEY: actual (1) O

Φ(H) = trees(H)

5.2: Fibonacci Heaps (Analysis) T.S. 14 amortized (1) O amortized (d(n)) = (log n) O 6 O amortized (1) O

What if we don’t have marked nodes?

INSERT: actual (1) O EXTRACT-MIN: actual (trees(H) + d(n)) O DECREASE-KEY: actual (1) O

Φ(H) = trees(H)

7 18 38

24 17 23 21 39 41

26 46 30 52

35

5.2: Fibonacci Heaps (Analysis) T.S. 14 amortized (1) O amortized (d(n)) = (log n) O 6 O amortized (1) O

What if we don’t have marked nodes?

INSERT: actual (1) O EXTRACT-MIN: actual (trees(H) + d(n)) O DECREASE-KEY: actual (1) O

Φ(H) = trees(H)

7 18 38

24 17 23 21 39 41

26 46 30 52

35

5.2: Fibonacci Heaps (Analysis) T.S. 14 = (log n) 6 O

What if we don’t have marked nodes?

INSERT: actual (1) amortized (1) O O EXTRACT-MIN: actual (trees(H) + d(n)) amortized (d(n)) O O DECREASE-KEY: actual (1) amortized (1) O O

Φ(H) = trees(H)

7 18 38

24 17 23 21 39 41

26 46 30 52

35

5.2: Fibonacci Heaps (Analysis) T.S. 14 What if we don’t have marked nodes?

INSERT: actual (1) amortized (1) O O EXTRACT-MIN: actual (trees(H) + d(n)) amortized (d(n)) = (log n) O O 6 O DECREASE-KEY: actual (1) amortized (1) O O

Φ(H) = trees(H)

7 18 38

24 17 23 21 39 41

26 46 30 52

35

5.2: Fibonacci Heaps (Analysis) T.S. 14 If this was possible, then there would be a sorting algorithm with runtime o(n log n)!

Can we perform EXTRACT-MIN in o(log n)?

Crucial for many applications including shortest paths and minimum spanning trees! DELETE = DECREASE-KEY + EXTRACT-MIN

EXTRACT-MIN = MIN + DELETE

Summary

Operation Binomial heap Fibon. heap

MAKE-HEAP (1) (1) (1) (1) O O O O INSERT (1) (log n) (log n) (1) O O O O MINIMUM (n) (1) (log n) (1) O O O O EXTRACT-MIN (n) (log n) (log n) (log n) O O O O UNION (n) (n) (log n) (1) O O O O DECREASE-KEY (1) (log n) (log n) (1) O O O O DELETE (1) (log n) (log n) (log n) O O O O

5.2: Fibonacci Heaps (Analysis) T.S. 15 If this was possible, then there would be a sorting algorithm with runtime o(n log n)!

Crucial for many applications including shortest paths and minimum spanning trees! DELETE = DECREASE-KEY + EXTRACT-MIN

EXTRACT-MIN = MIN + DELETE

Summary

Can we perform EXTRACT-MIN in o(log n)?

Operation Linked list Binary heap Binomial heap Fibon. heap

MAKE-HEAP (1) (1) (1) (1) O O O O INSERT (1) (log n) (log n) (1) O O O O MINIMUM (n) (1) (log n) (1) O O O O EXTRACT-MIN (n) (log n) (log n) (log n) O O O O UNION (n) (n) (log n) (1) O O O O DECREASE-KEY (1) (log n) (log n) (1) O O O O DELETE (1) (log n) (log n) (log n) O O O O

5.2: Fibonacci Heaps (Analysis) T.S. 15 Crucial for many applications including shortest paths and minimum spanning trees! DELETE = DECREASE-KEY + EXTRACT-MIN

EXTRACT-MIN = MIN + DELETE

Summary

If this was possible, then there would be a sorting algorithm with runtime o(n log n)!

Can we perform EXTRACT-MIN in o(log n)?

Operation Linked list Binary heap Binomial heap Fibon. heap

MAKE-HEAP (1) (1) (1) (1) O O O O INSERT (1) (log n) (log n) (1) O O O O MINIMUM (n) (1) (log n) (1) O O O O EXTRACT-MIN (n) (log n) (log n) (log n) O O O O UNION (n) (n) (log n) (1) O O O O DECREASE-KEY (1) (log n) (log n) (1) O O O O DELETE (1) (log n) (log n) (log n) O O O O

5.2: Fibonacci Heaps (Analysis) T.S. 15 If this was possible, then there would be a sorting algorithm with runtime o(n log n)!

Can we perform EXTRACT-MIN in o(log n)?

Crucial for many applications including shortest paths and minimum spanning trees! DELETE = DECREASE-KEY + EXTRACT-MIN

EXTRACT-MIN = MIN + DELETE

Summary

Operation Linked list Binary heap Binomial heap Fibon. heap

MAKE-HEAP (1) (1) (1) (1) O O O O INSERT (1) (log n) (log n) (1) O O O O MINIMUM (n) (1) (log n) (1) O O O O EXTRACT-MIN (n) (log n) (log n) (log n) O O O O UNION (n) (n) (log n) (1) O O O O DECREASE-KEY (1) (log n) (log n) (1) O O O O DELETE (1) (log n) (log n) (log n) O O O O

5.2: Fibonacci Heaps (Analysis) T.S. 15 If this was possible, then there would be a sorting algorithm with runtime o(n log n)!

Can we perform EXTRACT-MIN in o(log n)?

Crucial for many applications including shortest paths and minimum spanning trees!

EXTRACT-MIN = MIN + DELETE

Summary

Operation Linked list Binary heap Binomial heap Fibon. heap

MAKE-HEAP (1) (1) (1) (1) O O O O INSERT (1) (log n) (log n) (1) O O O O MINIMUM (n) (1) (log n) (1) O O O O EXTRACT-MIN (n) (log n) (log n) (log n) O O O O UNION (n) (n) (log n) (1) O O O O DECREASE-KEY (1) (log n) (log n) (1) O O O O DELETE (1) (log n) (log n) (log n) O O O O

DELETE = DECREASE-KEY + EXTRACT-MIN

5.2: Fibonacci Heaps (Analysis) T.S. 15 If this was possible, then there would be a sorting algorithm with runtime o(n log n)!

Can we perform EXTRACT-MIN in o(log n)?

Crucial for many applications including shortest paths and minimum spanning trees!

Summary

Operation Linked list Binary heap Binomial heap Fibon. heap

MAKE-HEAP (1) (1) (1) (1) O O O O INSERT (1) (log n) (log n) (1) O O O O MINIMUM (n) (1) (log n) (1) O O O O EXTRACT-MIN (n) (log n) (log n) (log n) O O O O UNION (n) (n) (log n) (1) O O O O DECREASE-KEY (1) (log n) (log n) (1) O O O O DELETE (1) (log n) (log n) (log n) O O O O

DELETE = DECREASE-KEY + EXTRACT-MIN

EXTRACT-MIN = MIN + DELETE

5.2: Fibonacci Heaps (Analysis) T.S. 15 If this was possible, then there would be a sorting algorithm with runtime o(n log n)!

Can we perform EXTRACT-MIN in o(log n)?

DELETE = DECREASE-KEY + EXTRACT-MIN

EXTRACT-MIN = MIN + DELETE

Summary

Operation Linked list Binary heap Binomial heap Fibon. heap

MAKE-HEAP (1) (1) (1) (1) O O O O INSERT (1) (log n) (log n) (1) O O O O MINIMUM (n) (1) (log n) (1) O O O O EXTRACT-MIN (n) (log n) (log n) (log n) O O O O UNION (n) (n) (log n) (1) O O O O DECREASE-KEY (1) (log n) (log n) (1) O O O O DELETE (1) (log n) (log n) (log n) O O O O Crucial for many applications including shortest paths and minimum spanning trees!

5.2: Fibonacci Heaps (Analysis) T.S. 15 several lower bounds on the amortized cost in terms of the size of the heap and the number of operations less efficient than the original Fibonacci heap ⇒ marked bit is not redundant! ⇒

Brodal, Lagogiannis, Tarjan: Strict Fibonacci Heap (STOC’12) Strict Fibonacci Heap: pointer-based heap implementation similar to Fibonacci Heaps achieves the same cost as Fibonacci Heaps, but actual costs!

Li, Peebles: Replacing Mark Bits with Randomness in Fibonacci Heap (ICALP’15) Queries to marked bits are intercepted and responded with a random bit

Recent Studies

Fibonacci Numbers were discovered >800 years ago Fibonacci Heaps were developed by Fredman and Tarjan in 1984

5.2: Fibonacci Heaps (Analysis) T.S. 16 several lower bounds on the amortized cost in terms of the size of the heap and the number of operations less efficient than the original Fibonacci heap ⇒ marked bit is not redundant! ⇒

Li, Peebles: Replacing Mark Bits with Randomness in Fibonacci Heap (ICALP’15) Queries to marked bits are intercepted and responded with a random bit

Recent Studies

Fibonacci Numbers were discovered >800 years ago Fibonacci Heaps were developed by Fredman and Tarjan in 1984

Brodal, Lagogiannis, Tarjan: Strict Fibonacci Heap (STOC’12) Strict Fibonacci Heap: pointer-based heap implementation similar to Fibonacci Heaps achieves the same cost as Fibonacci Heaps, but actual costs!

5.2: Fibonacci Heaps (Analysis) T.S. 16 several lower bounds on the amortized cost in terms of the size of the heap and the number of operations less efficient than the original Fibonacci heap ⇒ marked bit is not redundant! ⇒

Recent Studies

Fibonacci Numbers were discovered >800 years ago Fibonacci Heaps were developed by Fredman and Tarjan in 1984

Brodal, Lagogiannis, Tarjan: Strict Fibonacci Heap (STOC’12) Strict Fibonacci Heap: pointer-based heap implementation similar to Fibonacci Heaps achieves the same cost as Fibonacci Heaps, but actual costs!

Li, Peebles: Replacing Mark Bits with Randomness in Fibonacci Heap (ICALP’15) Queries to marked bits are intercepted and responded with a random bit

5.2: Fibonacci Heaps (Analysis) T.S. 16 less efficient than the original Fibonacci heap ⇒ marked bit is not redundant! ⇒

Recent Studies

Fibonacci Numbers were discovered >800 years ago Fibonacci Heaps were developed by Fredman and Tarjan in 1984

Brodal, Lagogiannis, Tarjan: Strict Fibonacci Heap (STOC’12) Strict Fibonacci Heap: pointer-based heap implementation similar to Fibonacci Heaps achieves the same cost as Fibonacci Heaps, but actual costs!

Li, Peebles: Replacing Mark Bits with Randomness in Fibonacci Heap (ICALP’15) Queries to marked bits are intercepted and responded with a random bit several lower bounds on the amortized cost in terms of the size of the heap and the number of operations

5.2: Fibonacci Heaps (Analysis) T.S. 16 marked bit is not redundant! ⇒

Recent Studies

Fibonacci Numbers were discovered >800 years ago Fibonacci Heaps were developed by Fredman and Tarjan in 1984

Brodal, Lagogiannis, Tarjan: Strict Fibonacci Heap (STOC’12) Strict Fibonacci Heap: pointer-based heap implementation similar to Fibonacci Heaps achieves the same cost as Fibonacci Heaps, but actual costs!

Li, Peebles: Replacing Mark Bits with Randomness in Fibonacci Heap (ICALP’15) Queries to marked bits are intercepted and responded with a random bit several lower bounds on the amortized cost in terms of the size of the heap and the number of operations less efficient than the original Fibonacci heap ⇒

5.2: Fibonacci Heaps (Analysis) T.S. 16 Recent Studies

Fibonacci Numbers were discovered >800 years ago Fibonacci Heaps were developed by Fredman and Tarjan in 1984

Brodal, Lagogiannis, Tarjan: Strict Fibonacci Heap (STOC’12) Strict Fibonacci Heap: pointer-based heap implementation similar to Fibonacci Heaps achieves the same cost as Fibonacci Heaps, but actual costs!

Li, Peebles: Replacing Mark Bits with Randomness in Fibonacci Heap (ICALP’15) Queries to marked bits are intercepted and responded with a random bit several lower bounds on the amortized cost in terms of the size of the heap and the number of operations less efficient than the original Fibonacci heap ⇒ marked bit is not redundant! ⇒

5.2: Fibonacci Heaps (Analysis) T.S. 16 all this requires key values to be in a universe of size u!

Outlook: A More Efficient for fixed Universe

Operation Fibonacci heap amortized cost actual cost INSERT (1) (log log u) O O MINIMUM (1) (1) O O EXTRACT-MIN (log n) (log log u) O O MERGE/UNION (1) - O DECREASE-KEY (1) (log log u) O O DELETE (log n) (log log u) O O SUCC - (log log u) O PRED - (log log u) O MAXIMUM - (1) O

5.2: Fibonacci Heaps (Analysis) T.S. 17 Outlook: A More Efficient Priority Queue for fixed Universe

Operation Fibonacci heap Van Emde Boas Tree amortized cost actual cost INSERT (1) (log log u) O O MINIMUM (1) (1) O O EXTRACT-MIN (log n) (log log u) O O MERGE/UNION (1) - O DECREASE-KEY (1) (log log u) O O DELETE (log n) (log log u) O O SUCC - (log log u) O PRED - (log log u) O MAXIMUM - (1) O

all this requires key values to be in a universe of size u!

5.2: Fibonacci Heaps (Analysis) T.S. 17