It is the jump search algorithm 2.3.
Any hints or anything will be of help thank you.


Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 4, 2015, 1:48 PM EST
The only awkward point is that Lists are zero based in C# whereas the algorithm seems to be assuming that they're 1-based. I've therefore reduced the index by 1 to allow for this:
VulpesRank #55 · 29.2K reputationPosted Feb 5, 2015, 7:29 AM EST
So, I've simply translated the pseudo-code into C# code. As previously mentioned, the only awkward point is that List
No definition was given for the LINEAR.SEARCH method so I simply assumed that we're supposed to iterate through the list, returning the 1-based index if X is found or 0 otherwise.
The part between the {..} is simply a comment but I used the information in that to check the arguments are acceptable and consistent with each other.
Thinking about it some more, perhaps we ought to add another line to make sure 'upper' isn't more than the number of elements in the list:
if (upper > list.Count) throw new ArgumentException("upper can't be more than the number of elements in the list");
Philip Harris36 reputationPosted Feb 4, 2015, 2:41 PM EST
Philip Harris36 reputationPosted Feb 5, 2015, 9:28 AM EST
Many thanks Vulpes.... YOU ROCK!