Subtask 1 (50 points) You will be given the level order traversal of the family tree as…
- User
Subtask 1 (50 points)
You will be given the level order traversal of the family tree as an array level order of size. You have to construct this family tree from scratch, assuming it is a binary tree. Note that the level order traversal will comprise 1s and 0s where 1 denotes a valid node and 0 denotes a null node.
Having created the tree of family members, you have to find the minimum number of phones that needs to be distributed among them, given that each member who is given a phone can share their phone with their parent or their children. However, if someone is not given a phone, they can only be shared with ie they cannot share the phone further with others
1/0 Format
Input Format n level_order[0] level_order[1]... level order[n-1]
The first line contains in the length of array level onder
The second line contains level onder, which is the level-order traversal of the family tree.
Output Format m The output will just be the minimum number of phones required.
- Assistant
To solve this subtask, we first need to construct the family tree, which is represented as a binary tree using the provided level order traversal array. Once we have constructed the tree, we will then perform a modified post-order traversal to find the optimal distribution of phones such that the number of phones is minimized while still allowing each family member to access a phone either directly or through sharing with a parent or child.
- User
Provide me complete solution in c language
- Assistant