Re: [algogeeks] Local Minima in Unsorted Array

2012-08-09 Thread Abhishek Sharma
http://courses.csail.mit.edu/6.006/spring11/lectures/lec02.pdf

On Mon, Aug 6, 2012 at 12:19 AM, dheeraj chawla dheeraj.chawla...@gmail.com
 wrote:

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

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

 while(startend)
 {
   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(startend)
   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.


-- 
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.



Re: [algogeeks] Local Minima in Unsorted Array

2012-08-05 Thread payal gupta
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.



Re: [algogeeks] Local Minima in Unsorted Array

2012-08-05 Thread dheeraj chawla
hello guys, check this code n tell me if i m worng

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

while(startend)
{
  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(startend)
  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.



Re: [algogeeks] Local Minima in Unsorted Array

2012-08-04 Thread Ashish Goel
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.



[algogeeks] Local Minima in Unsorted Array

2012-08-03 Thread shady
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.



Re: [algogeeks] Local Minima in Unsorted Array

2012-08-03 Thread Suryabhan Singh
u can use heap sort

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.