1
$\begingroup$

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$

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

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.