Binary search: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 12: Line 12:
Given the starting point of a range, the ending point of a range, and the "secret value", implement a binary search through a sorted integer array for a certain number. Implementations can be recursive or iterative (both if you can). Print out whether or not the number was in the array afterwards. If it was, print the index also. The algorithms are as such (from [http://en.wikipedia.org/wiki/Binary_search the wikipedia]):
Given the starting point of a range, the ending point of a range, and the "secret value", implement a binary search through a sorted integer array for a certain number. Implementations can be recursive or iterative (both if you can). Print out whether or not the number was in the array afterwards. If it was, print the index also. The algorithms are as such (from [http://en.wikipedia.org/wiki/Binary_search the wikipedia]):


=Examples=
==Pseudocode==
==Pseudocode==
===Recursive===
===Recursive===
Line 43: Line 42:
}
}


=Examples=
=={{header|Haskell}}==
=={{header|Haskell}}==