Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Returns:
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
If it is not sorted, the results are undefined.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Stephan - are you sure?
Tom - so what's your conclusion?
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Because one of the possible answers was not "results can not be determined"For instance, why do you think Sun's answer is bogus?
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Sandra Bachan wrote:Sun Web Learning Center code
Need to understand what is going on BEFORE sorting.
According to Sun, two possible outputs are
-1 1
and
7 1
Where do the values of -1 and 7 come from. I can understand that Arrays.binarySearch("b") outputs 1 because that is where b is located AFTER sorting.
OCPJP 86%
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
bhanu chowdary wrote:
Sandra, do you know how a binary search works?
bhanu chowdary wrote:
I do not know what are the other options available apart from the above two, but i am guessing that only these two have their second output as 1. Since the question has "possible outputs" in it <any number> and 1 would do i guess.
Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Himanshu S. Soni wrote:i get it how the output
-1 and 1 comes
but i have no clue how 7 comes in picture.
Before using BinarySearch, you need to know how this works.
Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Searches the specified array for the specified object using the binary search algorithm. The array must be sorted into ascending order according to the natural ordering of its elements (as by the sort(Object[]) method) prior to making this call. If it is not sorted, the results are undefined. (If the array contains elements that are not mutually comparable (for example, strings and integers), it cannot be sorted according to the natural ordering of its elements, hence results are undefined.) If the array contains multiple elements equal to the specified object, there is no guarantee which one will be found.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
love demgracy, knowledge demogracy, open source and Java - OCPJP 76%
BinarySearch starts at the middle location. In this case it finds the key on its first comparison. Bert will tell you that it doesn't matter that it is a BinarySearch though (therefore you should ignore the algorithm) and you should expect any answer ranging from 0 through to 5 since the contract states "If the array contains multiple elements equal to the specified object, there is no guarantee which one will be found.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Ruth Stout was famous for gardening naked. Just like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|