# Heaps, Binary Files and Bit Sets

A complete binary tree B, containing 50 nodes, is stored in a vector.

(a). What is the level of the tree?

(b). How many nodes are leaf nodes? Nonleaf nodes?

(c). What is the index of the parent of B[35]?

(d). What are the indices of the children of node B[20]?

(e). What is the index of the first node with no children? With one child?

(f). What are the indices for all nodes at level 4 in the tree?

https://brainmass.com/computer-science/trees/heaps-binary-files-bit-sets-270726

#### Solution Preview

The binary tree is as follows.

Level 1: B[0]

Level 2: B[1], B[2]

Level 3: B[3], B[4], B[5], B[6]

Level 4: B[7], B[8], B[9], B[10], B[11], B[12], B[13], B[14]

Level 5: B[15], ..., B[30]

Level 6: B[31], ..., ...

#### Solution Summary

Heaps, binary files and bit sets are examined.

$2.19