To find a local minimum in a field

AI Thread Summary
The discussion focuses on finding a local minimum in a field of N integers, where A[0] and A[N+1] are defined as infinity. A local minimum is characterized by the condition A[i-1] >= A[i] <= A[i+1]. The initial algorithm presented operates in O(n) time complexity, which is insufficient for the goal of achieving better than O(n). A suggestion is made to improve the algorithm by using a conditional control statement to test every other value, potentially reducing the number of comparisons. However, it is noted that this approach still results in O(n) complexity. The conversation hints at exploring divide-and-conquer strategies to achieve a more efficient solution, emphasizing that there is at least one local minimum in the field.
alejandrito
Messages
7
Reaction score
0
Let A be a field of N integers and A[0] = A[N+1] = infinity. Element A is called a local minimum if A[I-1] >= A <= A[I+1]. Find an alogrithm that will find some local minimum in a time asymptotically better then O(n). Hint: Consider that in each field deffined as before there must exist at least one local minimum.
The best algorithm (or programme in Pascal) I´ve found is the following:
...
while (A[I+1] > A[I+2] and I<N-1) do I:=I+1;
LOCMIN:=A[I+1];
...
which needs maximally N-1 steps to find a local minimum, but this is not enough if we want the asymptotical difficulty better then O(n). Could anybody help me with improving the algorithm? Thanks
 
Technology news on Phys.org
I haven't tried working this out in detail, but with a clever conditional control statement for the loop you should be able to find a local min testing only every other value, rather than every value(using I=I+2). I think. I might be wrong, but it may be worth a try.
 
Hint: does http://en.wikipedia.org/wiki/Divide-and-conquer_algorithm" mean anything to you?


(Sorry, franznietzsche's idea doesn't solve the problem because O(n/2) is still O(n).)
 
Last edited by a moderator:
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top