# Immediate positions algorithm?

Im studying for the computer science subject GRE test, as an exercise i need to implement the followin algorithm in java, any idea on how to aproach it?.

Given a set $X$ and $z$ not in $X$, indicate between which would be the immediate positions $z$ in $X$

• Your question needs clarification. Is there a total order allowing the comparison between $z$ and the elements of $X$? – J.-E. Pin Sep 25 '13 at 5:31

It depends on how $X$ is given. If $X$ is given unsorted, find the minimum element larger than $z$, and the maximum element smaller than $z$. If $X$ is given sorted, use binary search.