Re: [algogeeks] Link list Q

2011-12-01 Thread Amit Chauhan
Option (c) is correct. detects the loop in singly linked list ** On Thu, Dec 1, 2011 at 1:42 PM, Vijay Khandar vijaykhand...@gmail.comwrote: What does the following program do on the singly linked list? p=head; q=head-next; while(p!=null q!null) { if(p==q) { exit(0) } p=p-next;

Re: [algogeeks] Re: finding whether sum of two numbers of array is equal to given number or not ? plz tell why my this is not working for x=10,11,13 values

2011-06-11 Thread Amit Chauhan
Hi, For x = 10,11,12,13 it is going in infinite loop. Your recursive call for binary_search function is going in infinite loop. So please look in to the logic for binary search function. And one more thing once you sort the array and after this you can search the pair in linear time { for

Re: [algogeeks] Re: plz tell what is wrong in my this code... This code is for finding whether there are two numbers in array whose sum is exactly equal to given value x or not ... program is given as

2011-06-11 Thread Amit Chauhan
Hi, Your recursive call for binary_search function is going in infinite loop. So please look in to the logic for binary search function. And one more thing once you sort the array and after this you can search the pair in linear time { for searching the element}. *Thanks and Regards * *Amit K

[algogeeks] Re: minimum difference.

2009-09-02 Thread Amit Chauhan
It won't work for following case If suppose array contains the following integers 10 5 1 15 9 then according to you answer would be diff = |1-5| = 4 but correct answer is diff = |9-10| = 1 Thanks and Regards Amit Chauhan http://web.iiit.ac.in/~chauhan Mobile : +91-9966347645 Y! IM : amitc_