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;
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
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
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_