Question: Please code in C++ with side comments to understand In this assignment you need to create two Binary Tree Data Structures. One must be stored
Please code in C++ with side comments to understand 

In this assignment you need to create two Binary Tree Data Structures. One must be stored as a doubly linked list and the other in an array The data type of the array or linked list node will be a class called "item" with three public members -int id -int value string name We will be using these structures in future assignments, so for now keep the string member with just the empty string. Initialize the id to be -1 for all items. Then as you create each one, increase the id of each node by 1 Make sure you don't have duplicate id values. Linked List: For the linked list version we want to have each node have a pointer to its parent and to its children(s) which can be0,1, or 2 (binary tree). So for example a node could contain: Node: parent "leftchild rightchild tern If the node happens to be the head of the tree, assig nullptr to the parent. Similarly, for any lacking children use nullptr. Array: For the array. Declare an array of type item and initialize the array with all ids being -1. We will use -1 to indicate an empty spot in the array-such as if the node has no children. Use a power of2 (1) for array size and as you fill it up (1, 3,7, 15, 31..) copy over to a new array to not run out of space. To insert nodes, the head will always go in index 0, but the children will go: Left: Parent2+1 Right: Left +1 (Where Parent stands for the index where parent is) Inversely if you are trying to access the Parent of a Node in Index 9 (Left Children): (9-12-4 Or for the right children: (10-2)2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
