Open mihai511 opened 5 years ago
struct min_heap min_heap_tree(struct min_heap root, int arr[], int i, int n){ if (i < n){ struct min_heap new_node = (struct min_heap)malloc(sizeof(struct min_heap)); new_node->data = arr[i]; new_node->left = NULL; new_node->right = NULL; root = new_node;
root->left = min_heap_tree(root->left, arr, 2 * i + 1, n);
root->right = min_heap_tree(root->right, arr, 2 * i + 2, n);
}
return root;
}
struct min_heap min_heap_tree(struct min_heap root, int arr[], int i, int n){ if (i < n){ struct min_heap new_node = (struct min_heap)malloc(sizeof(struct min_heap)); new_node->data = arr[i]; new_node->left = NULL; new_node->right = NULL; root = new_node;
}