I am having problem understanding as to what the following statement means(not the tertiary operator part) –
return(((*data)*(tmp_left)<(*data)*(tmp_right))?tmp_left:tmp_right);
where data is a pointer and tmp_left is a variable of type int. This line is in relation to a tree structure, if that helps.
To be exact I want to know what does (*data) mean? Is it a value pointed to by the pointer or a member variable accessed by it? What does the asterisk ‘*’ between the pointer and a variable signify? *(tmp_left)
Without knowing the data types, and knowing that it’s used in a tree (assuming it’s a BST) this looks like a comparison of data values.
In essence, when you have a BST you will either insert nodes to the left of the immediate node or the right of the immediate node. It looks like the data value is contained within the node and is the pointer. So, (*data) derferences the node. The (*data) * tmp_left multiplies the values.
The rest is a comparison statement. If the left hand side of the expression is less than the right hand size, use the tmp_left data value. Otherwise, continue to the right.