Question
A C function insert(Node* root, int data) for a BST.
#include typedef struct Node { int data; struct Node *left, *right; } Node; Node* newNode(int data) { Node* temp = (Node*)malloc(sizeof(Node)); temp->data = data; temp->left = temp->right = NULL; return temp; } Node* insert(Node* root, int data) { if (root == NULL) { return newNode(data); } if (data < root->data) { root->left = insert(root->left, data); } else { // Handles data >= root->data root->right = insert(root->right, data); } // Bug: Missing 'return root;' here } If this insert function is used to build a BST (e.g., root = insert(root, 50); root = insert(root, 30);), what is the most critical issue that will arise due to the missing return root; statement?Solution
• Why Correct Answer (C): The function will return an undefined value, potentially corrupting tree links or causing a crash. o This accurately describes the consequence of undefined behavior when a non-void function fails to return a value. The root pointer in the calling scope will receive an unpredictable value, leading to data corruption or a crash.
61, 48, ?, 35, 87, 22
92, 51, 21, 13.5, x, 4.25
find the value of (10x + x -5)?
The sequence below has a single missing term denoted by “?”:
3, 5, 11, 23, 47, ?
Condition I: The first difference (T₂ − T₁, T�...
Given below are two number series i.e. 'I' and 'II' where the wrong (odd one out) number in each series 'I' and 'II' is 'P' and 'Q', respectively. You h...
150 160 140 ? 130 180
...7 13 15 29 31 57
...3 5 ? 75 1125 84375
...3 4.5 6.75 10.125 15.1875 22.78125 ?
...840 400 180 ? 15 -12.5
...7 12 33 ? 635 3804
...