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

Given the following code: struct tree data t int value; struct tree node struct

ID: 3742870 • Letter: G

Question

Given the following code: struct tree data t int value; struct tree node struct tree.node *left; struct tree.node xright; struct tree_data data; b; struct tree_node root; struct tree_node sample-&root Fill in the missing references in the examples below by dragging the appropriate operator in the region below to the blank spaces in the sample code: 1. sample datavalue-10; 2. rootleft sample 3. root | | left| | left = sample; 4. rootright &root 5. sample | | right =root| |left; 6. rooteft data value 99;

Explanation / Answer

-> is used in case of pointer as

a -> b

stands for

(*a).b

(.) is used in case of a variable.

(1)

sample is a pointer. So, to access data, we use ->. Also, data is a variable. So, we use (.)

sample->data.value = 10;

(2)

root is a variable. So, to access left, we use (.)

root.left = sample;

(3)

root is a variable. So, to access left, we use (.). Also, left is a pointer. So, to access another left, we use ->

root.left->left = sample;

(4)

root is a variable. So, to access right, we use (.).

root.right = &root;

(5)

sample is a pointer. So, to access right, we use (->). Also, root is a variable. So, to access left, we use (.)

sample->right = root.left

(6)

root is a variable. So, to access left, we use (.). Also, left is a pointer. So, to access data, we use ->. Also, data is a variable, so to access value, we use (.)

root.left->data.value = 99;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote