Interview Questions

Whats a Linked List ? Given Two linked list forming a Y shaped linked list ...

Microsoft Interview Questions and Answers


(Continued from previous question...)

83. Whats a Linked List ? Given Two linked list forming a Y shaped linked list ...

Question:
Whats a Linked List ? Given Two linked list forming a Y shaped linked list . Find the intersecting node...where one list has more nodes than the other ? Runtime analysis etc etc .


maybe an answer:


In the case of sorted linked list
1.Make two pointers pointing to each head ptr1,ptr2.
2.if(ptr1-<data==ptr2-<data) two pointers are pointing same node return the current node
3.else if ptr1->data>ptr2->data then increment ptr1 to next node
4.else increment ptr2 to next node
5.goto second step


if linked list is not sorted one..
1.make two pointers pointing to each head.
2.find number of nodes in each pointers.
3.find the difference of each count
4.move the longest list pointer for above difference from the head
5.the move the each pointer,return the meeting point.

(Continued on next question...)

Other Interview Questions