mihai511 / test-laborator-AD

0 stars 0 forks source link

min_heap (inca nu e corect) #3

Open mihai511 opened 5 years ago

mihai511 commented 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;

}

mihai511 commented 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;

}