figure array representation of simple tree data structure figure direct children of the nodes in an array representation of tree data structure vector arraylist list figure does not specify how we would handle adding null references to the heap this varies from case to casesometimes null values are prohibited entirelyin other cases we may treat them as being smaller than any non-null valueor indeed greater than any non-null value you will have to resolve this ambiguity yourself having studied your requirements for the sake of clarity we will avoid the issue by prohibiting null values because we are using an array we need some way to calculate the index of parent nodeand the children of node the required expressions for this are defined as follows for node at index (index )/ (parent index index (left child index (right childin figure arepresents the calculation of the right child of ( )and bcalculates the index of the parent of (( )/ insertion designing an algorithm for heap insertion is simplebut we must ensure that heap order is preserved after each insertion generally this is post-insertion operation inserting value into the next free slot in an array is simplewe just need to keep track of the next free index in the array as counterand increment it after each insertion inserting our value into the heap is the first part of the algorithmthe second is validating heap order in the case of min-heap ordering this requires us to swap the values of parent and its child if the value of the child is the value of its parent we must do this for each subtree containing the value we just inserted