Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

printf ( \"\ \" ) ; // Last part of the question } 2. From C to C++ Searching a

ID: 3767846 • Letter: P

Question

printf ( " " ) ; // Last part of the question

}

2. From C to C++ Searching a Tree Consider the following data structure. struct node int x struct node left; struct node *right; The tedious code for the function setup-tree is given below. You can ignore the code for that function for now and just follow this tree: 3 4 10 11 12 (a) What does the following code print out? struct node *setup tree (void); void dfs (struct node p) printf("%d ", p->x); if (p->leftNULL) dfs (p->left) if (p->right !NULL) dfs (p->right); int main(int argc, char **argv) struct node *psetup tree dfs (p)

Explanation / Answer

Prints the preorder traversal of the tree:-

1 2 4 5 8 9 3 6 7 10 12 11