Which boolean expression indicates whether the items in two nodes (n and m) are the same.
Assume that neither n nor m is null.
1 / n == m
2 / n.item == m.item
3 / n.next == m.next
4 / None of the above
The answer to this question is the option 2 / n.item == m.item as this option indicates that the value of item in n and the value of item in m should be equal in order to get a Boolean expression as true otherwise it will give the expression as false. This is a correct option as we want to to compare the items of the two node if we see in the option 1 we are not comparing the item we are comparing the notes that can't be equal because of the next and the header value and in the option 3 we are comparing the next value of both the note which cannot be true as if they were be pointing to same node if option 3 needs to be true so we get to the conclusion that option 2 is correct
Get Answers For Free
Most questions answered within 1 hours.