If I have n element organized in sequence is a circle as x1, x2, x3,..,xn and the circle wraps around: xn will be followed by x1.
Each element can perform a search for any other element.
Each element can forward the query to its adjacent neighbor.
What is the performance of searching for an element xm in this circle if:
1- I allow the search to be in one direction only. i.e.: if Xi is searching for Xm, the search can only proceed sequentially from Xi-->Xi+1-->Xi+2... until Xm is found.
2- I allow the search to be bi-directional. i.e.: each element can forward the query either way. If Xi is searching for Xm, the query could go either: Xi-->Xi+1-->Xi+2...-->Xm or Xi-->Xi-1-->Xi-2...-->Xm
My intuition is that for the first case the worst case is if xm=xn ==> O(n) and for the second one the worst case would be if xm is in the middle between x1 and xn ==> is O(n/2)
Note: I can determine which direction the search can go for the second case. For example: If I put the positive elements on right side and the negative elements on the other side and I am performing my search from an element with the value 0. Element 0 knows that if the element I am looking for is positive I should search on the right. etc.