Question: C language the code must be in C language only After adding it should be converted back into heap shape , and only one function
C language the code must be in C language only After adding it should be converted back into heap shape , and only one function ,in the photo the struct "s can be used no imported libraries or new sub functions as the following given
void heap_insert (struct heap * heap , int key ){
// ---the code
}

We have seen the implementation of the heap data structure with arrays. Let's assume that the heap data structure is implemented with the modified binary tree nodes defined below. The parent variable in the data structure "node" is the pointer to the parent of the corresponding node (added to provide access from a node to its parent). The "last_added" variable in the heap data structure shows the sign of the node that was last added to the data structure. Accordingly, write the function whose definition is given below and adds to the heap? struct node { int key; struct node *parent, *left_link, *right_link; }; struct heap{ struct dugum *root; struct dugum *last_added; } void heap_insert(struct heap *heap, int key){ //---the code --- }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
