Complete the code to check if the current node is NULL.
if (root [1] NULL) { return; }
We use '==' to compare if the pointer root is NULL.
Complete the code to print the node's data.
printf("%d ", root->[1]);
The node's value is stored in the data field.
Fix the error in the recursive call to traverse the left subtree.
leftSideViewUtil(root->[1], level + 1, &maxLevel);
To get the left side view, we first traverse the left child using root->left.
Fill both blanks to update the maxLevel and check if current level is first visit.
if (level > *[1]) { printf("%d ", root->data); *[2] = level; }
We compare level with *maxLevel and update *maxLevel when a new level is visited.
Fill all three blanks to complete the function signature and initial call.
void leftSideViewUtil(struct Node* [1], int level, int* [2]) { if ([1] == NULL) return; if (level > *[2]) { printf("%d ", [1]->data); *[2] = level; } leftSideViewUtil([1]->left, level + 1, [2]); leftSideViewUtil([1]->right, level + 1, [2]); } void leftSideView(struct Node* root) { int maxLevel = 0; leftSideViewUtil(root, [3], &maxLevel); }
The function uses root as the node pointer, maxLevel as the pointer to max level, and starts traversal at level 1.
