Interview Questions

How do you test function Add that adds two linked lists?

Software QA/Tests Interview Questions from Microsoft


(Continued from previous question...)

How do you test function Add that adds two linked lists?

Question:
How do you test function Add that adds two linked lists?


maybe an answer:


We can implement this recursively by adding node by node of two link list.
Where:
result=(node1+node2+earlier carry)%10
if((node1+node2)>10) then carry a 1 to the next addition.

Add the tails of the two nodes with passing along with carry.
Expample : List1 : 4->5->6 and List 2 : 4->5->2 Then result = 8->0->9

(Continued on next question...)

Other Interview Questions