C.A.R. Hoare wrote:There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.
Junilu Lacar wrote:EDIT: Actually, a call to a correct implementation of binSearch() would probably look more like this
where binSearch() returns the index of the given number in the specified array or -1 if the number isn't in the array.
Junilu Lacar wrote:And please don't quote an entire response (especially one of mine because they tend to be long) if you can quote just the relevant parts that pertain to your reply. Long quotes make the thread harder to read and follow.
Naziru Gelajo wrote:The Binary search searches for multiple occurrences of a number per row from a text file.
There are three kinds of actuaries: those who can count, and those who can't.
Junilu Lacar wrote:
Naziru Gelajo wrote:The Binary search searches for multiple occurrences of a number per row from a text file.
What should this so-called "binary search" do if a row had these numbers in it: {4, 4, 4, 6, 9, 10, 15} and you were looking for 4?
Just so you know, the description of your search algorithm does not fit the traditional definition of a binary search and while you may still be employing a half-interval search, finding duplicates is not part of the binary search algorithm itself.
Naziru Gelajo wrote:
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:I know the assignment. It is guaranteed that the 2D array has the property that each column is sorted, from low to high. And that it is mandatory to use a BinarySearch to get the count of some value. Now, that changes much!
Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|