@sunny : thanks ..i got it...

On Sun, Jul 10, 2011 at 5:55 AM, sunny agrawal <sunny816.i...@gmail.com>wrote:

> Longest AP for that Example is of 7 elements........
> 2,4,6,8,10,12,14
> now see your mistake .......
> as i have already told you that u r looking for only contiguous AP's and
> that won't work
>
>
> On Sun, Jul 10, 2011 at 7:18 PM, Yogesh Yadav <medu...@gmail.com> wrote:
>
>> @sunny: my algo will give 6 as answer ....and i guess its right... if am
>> wrong plz explain where and why my logic is wrong
>>
>> On Sun, Jul 10, 2011 at 5:37 AM, sunny agrawal 
>> <sunny816.i...@gmail.com>wrote:
>>
>>> @Yogesh
>>> your solution will give maximum Contiguous AP only
>>> it will fail for the array A[] = {1,2,3,4,5,6,8,10,12,14}
>>> your algo will give output that there is an Longest AP of 6 elements
>>> which is wrong
>>>
>>> checkout this <http://theory.cs.uiuc.edu/%7Ejeffe/pubs/pdf/arith.pdf>for an 
>>> O(n^2) algorithm
>>>
>>>
>>> On Sun, Jul 10, 2011 at 7:01 PM, Yogesh Yadav <medu...@gmail.com> wrote:
>>>
>>>> @raj :
>>>>
>>>> array a[]= 2,3,5,6,7,8,10,12
>>>> diff[]=       1,2,1,1,1,2,2
>>>>
>>>> maxcount=tempcount=1   // because am not takin in consideration of 0th
>>>> index value of diff[]
>>>>
>>>> now in for loop
>>>> for j=1
>>>> check diff[j]==diff[j-1] //not equal
>>>> so check tempcount>maxcount or not  //its also not
>>>> so maxcount remains same and tempcount becomes 1 again
>>>>
>>>> now for j=2
>>>>
>>>> check diff[j]==diff[j-1] //not equal
>>>> so check tempcount>maxcount or not  //its also not
>>>> so maxcount remains same and tempcount becomes 1 again
>>>>
>>>> now for j=3
>>>>
>>>> check diff[j]==diff[j-1] // equal
>>>> so tempcount++;
>>>>
>>>> and so on....
>>>>
>>>>
>>>>
>>>>
>>>> On Sun, Jul 10, 2011 at 5:23 AM, raj singh <ankurkaku...@gmail.com>wrote:
>>>>
>>>>> @yogesh- can u explain with an example pls?
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> 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 algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> Sunny Aggrawal
>>> B-Tech IV year,CSI
>>> Indian Institute Of Technology,Roorkee
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> 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 algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to