hello guys, check this code n tell me if i m worng

int localminima(int a[],int start,int end)
{int mid;

    while(start<end)
    {
      mid=(start+end)/2;
    if(a[start]<a[start+1])
       return(1);
    else if(a[end-1]<a[end])
      return(1);
      else if(a[mid]<a[mid+1])
           end=mid-1;
       else
           start=mid+1;
    }

    if(start>end)
      return 0;

    return -1;
}

On Mon, Aug 6, 2012 at 12:15 AM, payal gupta <gpt.pa...@gmail.com> wrote:

> this could help although not true for many cases as said above
>
> http://ideone.com/w5gjK
>
>
>
> On Sun, Aug 5, 2012 at 8:40 AM, Ashish Goel <ashg...@gmail.com> wrote:
>
>> can you give an example of what do you mean by "Local" minima?
>> From Dave's example, it looks like the minima of the whole array..
>>
>> Best Regards
>> Ashish Goel
>> "Think positive and find fuel in failure"
>> +919985813081
>> +919966006652
>>
>>
>> On Fri, Aug 3, 2012 at 10:32 PM, shady <sinv...@gmail.com> wrote:
>>
>>> Hi,
>>> Can anyone tell how to find local minima in an unsorted array ?
>>> Recommended solution : O(log(n))
>>>
>>> Shady.
>>>
>>> --
>>> 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.
>>
>
>  --
> 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