Binomial trees and binomial heaps The binomial tree Bk is

Chapter 19, Problem 19-2

(choose chapter or problem)

Get Unlimited Answers
QUESTION:

The binomial tree \(B_{k}\) is an ordered tree (see Section B.5.2) defined recursively. As shown in Figure 19.6(a), the binomial tree \(B_{0}\) consists of a single node. The binomial tree \(B_{k}\) consists of two binomial trees \(B_{k-1}\) that are linked together so that the root of one is the leftmost child of the root of the other. Figure 19.6(b) shows the binomial trees \(B_{0}\) through \(B_{4}\)

a. Show that for the binomial tree \(B_{k}\),

1. there are \(2^{k}\) nodes,

2. the height of the tree is k,

3. there are exactly \(\left(\begin{array}{l}
k \\
i
\end{array}\right)\) nodes at depth i for \(i=0,1, \ldots, k\), and

4. the root has degree k, which is greater than that of any other node; moreover, as Figure 19.6(c) shows, if we number the children of the root from left to right by \(k-1, k-2, \ldots, 0\), then child i is the root of a subtree \(B_{i}\).

A binomial heap H is a set of binomial trees that satisfies the following properties

1. Each node has a key (like a Fibonacci heap).

2. Each binomial tree in H obeys the min-heap property.

3. For any nonnegative integer k, there is at most one binomial tree in H whose root has degree k.

b. Suppose that a binomial heap H has a total of n nodes. Discuss the relationship between the binomial trees that H contains and the binary representation of n. Conclude that H consists of at most \(\lfloor\lg n\rfloor+1\) binomial trees

Figure 19.6 (a) The recursive definition of the binomial tree \(B_k\). Triangles represent rooted subtrees. (b) The binomial trees \(B_0\) through \(B_4\). Node depths in \(B_4\) are shown. (c) Another way of looking at the binomial tree \(B_k\).

Suppose that we represent a binomial heap as follows. The left-child, right-sibling scheme of Section 10.4 represents each binomial tree within a binomial heap. Each node contains its key; pointers to its parent, to its leftmost child, and to the sibling immediately to its right (these pointers are NIL when appropriate); and its degree (as in Fibonacci heaps, how many children it has). The roots form a singly linked root list, ordered by the degrees of the roots (from low to high), and we access the binomial heap by a pointer to the first node on the root list.

c. Complete the description of how to represent a binomial heap (i.e., name the attributes, describe when attributes have the value NIL, and define how the root list is organized), and show how to implement the same seven operations on binomial heaps as this chapter implemented on Fibonacci heaps. Each operation should run in O.lg n/ worst-case time, where n is the number of nodes in the binomial heap (or in the case of the UNION operation, in the two binomial heaps that are being united). The MAKE-HEAP operation should take constant time.

d. Suppose that we were to implement only the mergeable-heap operations on a Fibonacci heap (i.e., we do not implement the DECREASE-KEY or DELETE operations). How would the trees in a Fibonacci heap resemble those in a binomial heap? How would they differ? Show that the maximum degree in an n-node Fibonacci heap would be at most [ Ig n].

e. Professor McGee has devised a new data structure based on Fibonacci heaps. A McGee heap has the same structure as a Fibonacci heap and supports just the mergeable-heap operations. The implementations of the operations are the same as for Fibonacci heaps, except that insertion and union consolidate the root list as their last step. What are the worst-case running times of operations on McGee heaps?

Questions & Answers

QUESTION:

The binomial tree \(B_{k}\) is an ordered tree (see Section B.5.2) defined recursively. As shown in Figure 19.6(a), the binomial tree \(B_{0}\) consists of a single node. The binomial tree \(B_{k}\) consists of two binomial trees \(B_{k-1}\) that are linked together so that the root of one is the leftmost child of the root of the other. Figure 19.6(b) shows the binomial trees \(B_{0}\) through \(B_{4}\)

a. Show that for the binomial tree \(B_{k}\),

1. there are \(2^{k}\) nodes,

2. the height of the tree is k,

3. there are exactly \(\left(\begin{array}{l}
k \\
i
\end{array}\right)\) nodes at depth i for \(i=0,1, \ldots, k\), and

4. the root has degree k, which is greater than that of any other node; moreover, as Figure 19.6(c) shows, if we number the children of the root from left to right by \(k-1, k-2, \ldots, 0\), then child i is the root of a subtree \(B_{i}\).

A binomial heap H is a set of binomial trees that satisfies the following properties

1. Each node has a key (like a Fibonacci heap).

2. Each binomial tree in H obeys the min-heap property.

3. For any nonnegative integer k, there is at most one binomial tree in H whose root has degree k.

b. Suppose that a binomial heap H has a total of n nodes. Discuss the relationship between the binomial trees that H contains and the binary representation of n. Conclude that H consists of at most \(\lfloor\lg n\rfloor+1\) binomial trees

Figure 19.6 (a) The recursive definition of the binomial tree \(B_k\). Triangles represent rooted subtrees. (b) The binomial trees \(B_0\) through \(B_4\). Node depths in \(B_4\) are shown. (c) Another way of looking at the binomial tree \(B_k\).

Suppose that we represent a binomial heap as follows. The left-child, right-sibling scheme of Section 10.4 represents each binomial tree within a binomial heap. Each node contains its key; pointers to its parent, to its leftmost child, and to the sibling immediately to its right (these pointers are NIL when appropriate); and its degree (as in Fibonacci heaps, how many children it has). The roots form a singly linked root list, ordered by the degrees of the roots (from low to high), and we access the binomial heap by a pointer to the first node on the root list.

c. Complete the description of how to represent a binomial heap (i.e., name the attributes, describe when attributes have the value NIL, and define how the root list is organized), and show how to implement the same seven operations on binomial heaps as this chapter implemented on Fibonacci heaps. Each operation should run in O.lg n/ worst-case time, where n is the number of nodes in the binomial heap (or in the case of the UNION operation, in the two binomial heaps that are being united). The MAKE-HEAP operation should take constant time.

d. Suppose that we were to implement only the mergeable-heap operations on a Fibonacci heap (i.e., we do not implement the DECREASE-KEY or DELETE operations). How would the trees in a Fibonacci heap resemble those in a binomial heap? How would they differ? Show that the maximum degree in an n-node Fibonacci heap would be at most [ Ig n].

e. Professor McGee has devised a new data structure based on Fibonacci heaps. A McGee heap has the same structure as a Fibonacci heap and supports just the mergeable-heap operations. The implementations of the operations are the same as for Fibonacci heaps, except that insertion and union consolidate the root list as their last step. What are the worst-case running times of operations on McGee heaps?

ANSWER:

Step 1 of 5

a)

1. Binomial tree Bk consists of two copies of , and so  has  nodes.

2. The size of one  is increased by one because of the way in which the two copies of  are linked to form . The maximum depth of a node in  is one greater than the maximum depth in . By the inductive hypothesis, this maximum depth is .

3. The number of nodes at depth i in  is the number of nodes at depth i in  plus the number of nodes at depth  in . i.e, for ,  and only root is at depth 0. Suppose in  , the number of nodes at depth i is , in , the number of nodes at depth i is .

4. The only node with greater degree in  than in  is the root, which has one more child than in .

Add to cart


Study Tools You Might Need

Not The Solution You Need? Search for Your Answer Here:

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back