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.
In Section 2(10) of the Bharatiya Nyaya Sanhita, 2023, the definition of gender now encompasses ________________.
“Registered office of company” is governed by which section?
What is e-commerce?
Which of the following is not a main principle of developing scientific advice at Codex?
Which of the following statements correctly reflects the power of the authorities under the PMLA regarding provisional attachment of property?
What is the condition for an action or belief to be considered in "good faith" as per IPC?
The importance of knowledge and communication, in formation of a contract was laid down in_____________
What does the principle of Res Gestaeunder Section 6 of the Indian Evidence Actstate?
The ______________ shall appoint a person who is qualified to be appointed a Judge of a High Court to be Advocate General for the State
In case of election of a President the electoral college consists of?