• Home
  • Textbooks
  • Data Structures and Algorithms in C++
  • Multiway TreEs

Data Structures and Algorithms in C++

Adam Drozdek

Chapter 7

Multiway TreEs - all with Video Answers

Educators


Chapter Questions

Problem 1

What is the maximum number of nodes in a multiway tree of height $h$ ?

Check back soon!
01:59

Problem 2

How many keys can a B-tree of order $m$ and of height $h$ hold?

Nick Johnson
Nick Johnson
Numerade Educator

Problem 3

Write a function that prints out the contents of a B-tree in ascending order.

Check back soon!

Problem 4

The root of a $\mathrm{B}^*$-tree requires special attention since it has no sibling. A split does not render two nodes two-thirds full plus a new root with one key. Suggest some solutions to this problem.

Check back soon!
00:59

Problem 5

Are B-trees immune to the order of the incoming data? Construct B-trees of order 3 (two keys per node) first for the sequence 1,5,3,2,4 and then for the sequence $1,2,3$, 4,5 . Is it better to initialize B-trees with ordered data or with data in random order?

James Kiss
James Kiss
Numerade Educator

Problem 6

Draw all ten different B-trees of order 3 which can store 15 keys and make a table that for each of these trees shows the number of nodes and the average number of visited nodes (Rosenberg and Snyder 1981). What generalization can you make about them? Would this table indicate that (a) the smaller the number of nodes, the smaller the average number of visited nodes and (b) the smaller the average number of visited nodes, the smaller the number of nodes? What characteristics of the B-tree should we concentrate on to make them more efficient?

Check back soon!

Problem 7

In all our considerations concerning B-trees, we assumed that the keys are unique. However, this does not have to be the case since multiple occurrences of the same key in a B-tree do not violate the B-tree property. If these keys refer to different objects in the data file (e.g., if the key is a name, and many people can have the same name), how would you implement such data file references?

Check back soon!

Problem 8

What is the maximum height of a $\mathrm{B}^{+}$-tree with $n$ keys?

Check back soon!
02:40

Problem 9

Occasionally, in a simple prefix $\mathrm{B}^{+}$-tree, a separator can be as large as a key in a leaf. For example, if the last key in one leaf is "Herman" and the first key in the next leaf is "Hermann," then "Hermann" must be chosen as a separator in the parent of these leaves. Suggest a procedure to enforce the shorter separator.

Maxime Rossetti
Maxime Rossetti
Numerade Educator

Problem 10

Write a function that determines the shortest separator for two keys in a simple prefix $\mathrm{B}^{+}$-tree.

Check back soon!
01:22

Problem 11

Is it a good idea to use abbreviated forms of prefixes in the leaves of prefix $B^{+}$-trees?

Natalie Johns
Natalie Johns
Numerade Educator
03:53

Problem 12

If in two different positions, $i$ and $j, i<j$, of a leaf in a bit-tree two $D$-bits are found such that $D_j=D_i$, what is the condition on at least one of the D-bits $D_k$ for $i<k<j$ ?

Chris Trentman
Chris Trentman
Numerade Educator
01:24

Problem 13

If key $K_i$ is deleted from a leaf of a bit-tree, then the D-bit between $K_{i-1}$ and $K_{i+1}$ has to be modified. What is the value of this D-bit if the values $D_i$ and $D_{i+1}$ are known? Make deletions in the leaf in Figure 7.17 to make an educated guess and then generalize this observation. In making a generalization, consider two cases: (a) $D_i<D_{i+1}$ and (b) $D_i>D_{i+1}$.

Doruk Isik
Doruk Isik
Numerade Educator
04:15

Problem 14

Write an algorithm that, for an R-tree, finds all entries in the leaves whose rectangles overlap a search rectangle $R$.

Chris Trentman
Chris Trentman
Numerade Educator

Problem 15

In the discussion of B-trees, which are comparable in efficiency to binary search trees, why are only B-trees of small order used and not B-trees of large order?

Check back soon!

Problem 16

What is the worst case of inserting a key into a $2-4$ tree?

Check back soon!
02:27

Problem 17

What is the complexity of the compresstrie() algorithm in the worst case?

Trang Hoang
Trang Hoang
Numerade Educator

Problem 18

Can the leaves of the trie compressed with compress $\operatorname{Trie}()$ still have abbreviated versions of the words, namely, parts which are not included in the nonterminal nodes?

Check back soon!
01:13

Problem 19

In the examples of tries analyzed in this chapter, we dealt with only 26 capital letters. A more realistic setting includes lowercase letters as well. However, some words require a capital letter at the beginning (names), and some require the entire word to be capitalized (acronyms). How can we solve this problem without including both lowercase and capital letters in the nodes?

Ernest Castorena
Ernest Castorena
Numerade Educator
03:19

Problem 20

A variant of a trie is a digital tree which processes information on the level of bits. Since there are only two bits, only two outcomes are possible. Digital trees are binary. For example, to test whether the word " $\mathrm{BOOK}$ " is in the tree, we do not use the first letter, "B," in the root to determine to which of its children we should go, but the first bit, 0 , of the first letter $(\operatorname{ASCII}(B)=01000010)$, on the second level, the second bit, and so on before we get to the second letter. Is it a good idea to use a digital tree for a spell checking program, as was discussed in the case study?

Carson Merrill
Carson Merrill
Numerade Educator