Interview Questions

Give atleast 10 test cases for a program which finds.......

Microsoft Interview Questions and Answers


(Continued from previous question...)

111. Give atleast 10 test cases for a program which finds.......

Question:
Give atleast 10 test cases for a program which finds and eliminates the duplicates in a singly linked list. assume it has all positive integers and returns the head of the linked list without the duplicates


maybe an answer:


Input Output explanation
1. 1->2->2->3->4 1->2->3->4 the sanity path
2. 1->1->2->3 1->2->3 border case duplicate at head
3. 1->2->3->3 1->2->3 border case duplicate at tail
4. 1->1->1->1 1-> all duplicates
5. 1->2->3->4 1->2->3->4 no duplicates
6. 1->2->3->2 1->2->3 duplicates in alternative positions (not consecutive)
7. Int.Min-1->2->1->Int.Max+1 2->1 test to make sure that the linked list structure handles numbers out of int range (the question didn't specify the range)
8. 1->2->1->2->3->3 1->2->3 each node has a duplicate
9. -1->0->1 throw exception should verify that erroroneous data is not being handled
10. 2->3->3->2->1 verify that the head is 2 making that the spec is being met
11. 1->1->1->1->1->1->1->2 1->2 just one non duplicate
12. test for a huge linked list that would potentially overflow memory and verify than the behavior is predictable



maybe an answer:


1.Empty Linked list
2.Linked list w.o any duplicated
3. LL with duplicated of the first elem
4. LL such that every node has a duplicate
5. LL such that first and last node has duplicate
6. Very Big linked list with no duplicate

(Continued on next question...)

Other Interview Questions