# Welcome back

## Find a book, put up your feet, stay awhile

Sign in with Facebook

Sorry, we are unable to log you in via Facebook at this time. Please try again later.

or

Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more

Download

Standard view

Full view

of .

Look up keyword

Like this

Share on social networks

2Activity

×

0 of .

Results for: No results containing your search query

P. 1

mc0080 set 1 july 2011Ratings: (0)|Views: 182|Likes: 2

Published by killer1

See more

See less

https://www.scribd.com/doc/74599625/mc0080-set-1-july-2011

03/25/2013

text

original

- 1 -

July 2011Master of Computer Application (MCA)

–

Semester 4MC0080

–

Analysis and Design of Algorithms

–

4 Credits(Book ID: B0891)Assignment Set

–

1Answer the following:Q1 . Describe the following:

o

Fibonacci Heaps

o

Binomial Heaps

Fibonacci Heaps

1) Structure of Fibonacci heaps

Like a binomial heap, a

Fibonacci heap

is a collection of min-heap-ordered trees. The trees in aFibonacci heap are not constrained to be binomial trees, however. Figure (a) shows an example of a Fibonacci heap.Unlike trees within binomial heaps, which are ordered, trees within Fibonacci heaps are rooted

but unordered. As Figure (b) shows, each node

x

contains a pointer

p [x]

to its parent and apointer child [x] to any one of its children. The children of

x

are linked together in a circular,

doubly linked list, which we call the

child list

of

x

. Each child y in a child list has pointers

left

[y]

and

right [y]

that point to y‟s left and right siblings, respectively. If node y is an only child,

then

left [y] = right [y] = y

. The order in which siblings appear in a child list is arbitrary.

- 2 -

Figure (a) A Fibonacci heap consisting of five min-heap-ordered trees and 14 nodes. Thedashed line indicates the root list. The minimum node of the heap is the node containing thekey 3. The three marked nodes are blackened. The potential of this particular Fibonacciheap is 5+2.3=11. (b) A more complete representation showing pointers p (up arrows), child(down arrows), and left and right (sideways arrows).

Two other fields in each node will be of use. The number of children in the child list of node x isstored in degree[x]. The Boolean-valued field mark[x] indicates whether node

x

has lost a childsince the last time

x

was made the child of another node. Newly created nodes are unmarked, anda node x becomes unmarked whenever it is made the child of another node.A given Fibonacci heap H is accessed by a pointer

min [H]

to the root of a tree containing a

minimum key; this node is called the

minimum node

of the Fibonacci heap. If a Fibonacci heapH is empty, then

min [H] = NIL

.The roots of all the trees in a Fibonacci heap are linked together using their left and right pointers

into a circular, doubly linked list called the

root list

of the Fibonacci heap. The pointer

min[H]

thus points to the node in the root list whose key is minimum. The order of the trees within aroot list is arbitrary.We rely on one other attribute for a Fibonacci heap H : the number of nodes currently in H is keptin n[H].

2) Potential function

For a given Fibonacci heap H, we indicate by

t (H)

the number of trees in the root list of H andby

m(H)

the number of marked nodes in

H

. The potential of Fibonacci heap

H

is then defined by(a)

For example, the potential of the Fibonacci heap shown in Figure 4.3 is

5+2.3 = 11. The potential of a set of Fibonacci heaps is the sum of the potentials of its constituent

- 3 -

Fibonacci heaps. We shall assume that a unit of potential can pay for a constant amount of work,where the constant is sufficiently large to cover the cost of any of the specific constant-timepieces of work that we might encounter.We assume that a Fibonacci heap application begins with no heaps. The initial potential,therefore, is 0, and by equation (a), the potential is nonnegative at all subsequent times.

3) Maximum degree

The amortized analyses we shall perform in the remaining sections of this unit assume that there

is a known upper bound

D(n)

on the maximum degree of any node in an n-node Fibonacci heap.

Binomial Heaps

A binomial heap

H

is a set of binomial trees that satisfies the following

binomial heapproperties.

1. Each binomial tree in

H

obeys the

min-heap property:

the key of a node is greater than orequal to the key of its parent. We say that each such tree is

min-heap-ordered.

2. For any nonnegative integer

k

, there is at most one binomial tree in

H

whose root has degree

k

.The first property tells us that the root of a min-heap-ordered tree contains the smallest key in thetree.The second property implies that an n-node binomial heap

H

consists of at most

[lg n] +

1

binomial trees. To see why, observe that the binary representation of n has

[lg n] + 1

bits,say , so that

. By property 1 of 4.4.2, therefore,binomial tree

B

i

appears in

H

if and only if bit

b

I

= 1

. Thus, binomial heap H contains at most

[lgn] + 1

binomial trees.

Q2 . If

2)(

3

nn f

,

1712037)(

2

nnng

then show that

)(

f Og

and

)(

gO f

Solution:

(i) For g = O (f), g (n) should be <= C. f (n) for all n >= k.When C = 53 and k = 3, we getg(n) <= C. f(n), which holds true.Therefore, g = O (f).(ii) For f not = to O (g), let us see the sample<= C.

Now, let‟s imply, we get

<= C. 174Further implying we get n < = 174 C for all n > = k.But for n = max {174 + 1, k}, the previous statement is not true.

- Read and print without ads
- Download to keep your version
- Edit, email or read offline

© Copyright 2015 Scribd Inc.

Language

Choose the language in which you want to experience Scribd:

Sign in with Facebook

Sorry, we are unable to log you in via Facebook at this time. Please try again later.

or

Password Reset Email Sent

Join with Facebook

Sorry, we are unable to log you in via Facebook at this time. Please try again later.

or

By joining, you agree to our

read free for two weeks

Unlimited access to more than

one million books

one million books

Personalized recommendations

based on books you love

based on books you love

Syncing across all your devices

Join with Facebook

or Join with emailSorry, we are unable to log you in via Facebook at this time. Please try again later.

Already a member? Sign in.

By joining, you agree to our

to download

Unlimited access to more than

one million books

one million books

Personalized recommendations

based on books you love

based on books you love

Syncing across all your devices

Continue with Facebook

Sign inJoin with emailSorry, we are unable to log you in via Facebook at this time. Please try again later.

By joining, you agree to our

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

CANCEL

OK

You've been reading!

NO, THANKS

OK

scribd