Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lecture Slides on Binomial Heaps - Data Structures and Algorithms | CS 112, Study notes of Computer Science

Material Type: Notes; Class: Intro to Computer Science II; Subject: Computer Science; University: University of San Francisco (CA); Term: Intersession 2008;

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-gj6
koofers-user-gj6 🇺🇸

3

(2)

10 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Data Structures and Algorithms
CS245-2008S-20
Binomial Heaps
David Galles
Department of Computer Science
University of San Francisco
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Lecture Slides on Binomial Heaps - Data Structures and Algorithms | CS 112 and more Study notes Computer Science in PDF only on Docsity!

Data Structures and Algorithms

CS245-2008S-20Binomial Heaps

David Galles Department of Computer ScienceUniversity of San Francisco

Binomial Trees Bis a tree containing a single node^0 To build

B:k

Start with

Bk−

Add

Bk−

as left subtree 1

Binomial Trees

B^0

B^1

B^2

B^3

B^4

Binomial Trees Equivalent defintion^ B

is a binomial heap with a single node 0 Bis a binomial heap withk

k^ children:

B... B^0

k−^1

Binomial Trees

B^0

B^1

B^2

B^3

B^4

Binomial Trees Properties of binomial trees

Bk

Contains

k^2 nodes

Has height

k

Contains

(^ )k i

nodes at depth

i^ for

i^ = 0

... k

Binomial Heaps

Binomial Heaps Representing Binomial Heaps^ Each node contains:

left child, right sibling, parent pointers degreee (is the tree rooted at this node

B,^0

B, etc.)^1 data Each list of children sorted by degree

Binomial Heaps How can we find the minimum element in abinomial heap? How long does it take?

Binomial Heaps How can we find the minimum element in abinomial heap?^ Look at the root of each tree in the list, findsmallest value How long does it take?^ Heap has

n^ elements

Represent

n^ as a binary number

Bis in heap iffk^

kth binary digit of

n^ is 1

Number of trees in heap

∈^ O

(lg^ n

Binomial Heaps Merging Heaps

H^1

and

H^2

Merge root lists of

H^1

and

H^2

Could now have two trees with same degree Go through list from smallest degree to largestdegree If two trees have same degree, combinethem into one tree of larger degree If three trees have same degree (how canthis happen?) leave one, combine other twointo tree of larger degree

Binomial Heaps

Binomial Heaps

Binomial Heaps