@aditya, Who said it's a Y shaped structure, It can very well has a cycle. Assume the case when the last node is not pointing to NULL but to a node in the list.
On Thu, Jan 6, 2011 at 7:45 PM, ADITYA KUMAR <[email protected]> wrote: > @vishal > saurabh is right > its merging at only one point its a Y-shaped structure > > > > On Thu, Jan 6, 2011 at 7:29 PM, vishal raja <[email protected]>wrote: > >> >> @sourabh, >> In addition to your solution, If there is any cycle(loop) exist in the >> link list your algo will fail. >> To solve this problem first detect this cycle if there is any and count >> the element in the cycle, and then you can do the mathematics. >> >> >> >> On Thu, Jan 6, 2011 at 6:51 PM, sourabh jakhar >> <[email protected]>wrote: >> >>> for second question calculate the difference in length of two linked >>> list. >>> and than shift the head of longest linked list to the calculated >>> difference. while the head of shorest is at the first node of that linked >>> list. >>> Than iterate both to see if info is equal and that is the merging point. >>> complexity-o(n). >>> hope this help >>> >>> >>> On Thu, Jan 6, 2011 at 6:48 PM, juver++ <[email protected]> wrote: >>> >>>> Yes, but recursion stack's size is limited instead of iterative version. >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]<algogeeks%[email protected]> >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> SOURABH JAKHAR,(CSE)(3 year) >>> ROOM NO 167 , >>> TILAK,HOSTEL >>> 'MNNIT ALLAHABAD >>> >>> >>> The Law of Win says, "Let's not do it your way or my way; let's do it the >>> best way." >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]<algogeeks%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<algogeeks%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Regards > Aditya Kumar > B-tech 3rd year > Computer Science & Engg. > MNNIT, Allahabad. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
