48.0k views
0 votes
typedef struct bitNode { int data; struct bitNode *left; struct bstNode *right; } bstNode; int solve(bstNode* root) { if (root == NULL) return 0; int res = root->data; int left = solve(root→left); int right = solve(root->right); if (left+right > res) res = left+right; printf("%d,", res); return res; }_____ , _____ , _____ , _____ ,_____ , _____ , _____ , _____ , _____ , _____

User Badweasel
by
3.9k points

1 Answer

4 votes

Answer:

The ten numbers to be filled in the blanks are: 18, 7, 7, 11, 18, 36, 3, 8, 13, 50.

Step-by-step explanation:

keeps on going to the left node until node->left == NULL;

now at Node 18;

left = right = 0; hence condition is not satisfied

18 is printed first.

the value 18 is returned .

Then we reach at 4;

from there we move to 7;

just like 18, similar things happen with 7 and 7 is printed, the value 7 is returned.

Now coming to Node 4,

left = 0, right = 7 ; hence the condition is satisfied & res = 7; 7 is printed.

For Node 16, left = 7 ; right = 11(but for this we visit 11 first and 11 is printed)

for 16; condition is satisfied; res = 7 + 11 = 18 ; 18 is printed

Now for 5; left = right = 18; the condition is satisfied; so res = 18 + 18 = 36; 36 is printed

Next we visit Node 3; 3 is printed & 3 is returned

Then Node 8 ; 8 is printed & 8 is returned

for Node 13; left = 3, right = 8 ; condition is not satisfied, 13 is printed.

For Node 50; left = 36 right = 13 ; condition is not satisfied hence 50 is printed.

So the order of printing is 18 7 7 11 18 36 3 8 13 50.

User Trey Hunner
by
4.3k points