133k views
2 votes
Assume that for some binary tree node implementation, a pointer requires 4 bytes and a data object requires 14 bytes. Further assume that we are storing a Full binary tree, that the internal nodes are implemented to store only two pointers (no data field), and that the leaf nodes store only a data field. Type a fraction (like "1/2") that represents the fraction of the total space taken up by overhead. Give your fraction in lowest terms.

1 Answer

4 votes

Final answer:

The fraction representing the overhead in a full binary tree with specified node implementations is 4/11. This fraction is obtained by calculating the overhead space of internal nodes compared to the total space used for both internal and leaf nodes.

Step-by-step explanation:

To calculate the space overhead in a Full binary tree with such node specifications, we must consider the sizes of pointers and data objects. Since internal nodes have only pointers with no data field, each internal node contributes 8 bytes of overhead (two pointers each of 4 bytes). Leaf nodes have no pointers but have a 14-byte data field instead. In a Full binary tree, there are always one more leaf nodes than internal nodes (if n is the number of internal nodes, then there are n+1 leaf nodes).

In a Full binary tree, every level is completely filled, and every node has two children except for leaf nodes. Let's denote the number of leaf nodes as L and the number of internal nodes as I. Since there is one more leaf node than internal nodes in a full binary tree, I = L - 1. We know that the total number of nodes N in a full binary tree is N = I + L. So, the total space can be computed as:

  • Space for internal nodes (I): I * 8 bytes (overhead for pointers)
  • Space for leaf nodes (L): L * 14 bytes (data)

To find the fraction of the total space taken up by overhead, we need to divide the space for internal nodes by the total space:

Overhead fraction = (I * 8) / (I * 8 + L * 14)

Substituting I = L - 1 into the overhead equation:

Overhead fraction = ((L - 1) * 8) / ((L - 1) * 8 + L * 14)

After simplifying the equation, we get:

Overhead fraction = 8/22

Reducing to lowest terms gives us:

Overhead fraction = 4/11

User Pastor Bones
by
7.5k points