Bifalgorithm post · Computer science one · Searching

What are the requirements for using binary search in Java?

What are the requirements for using binary search in Java? (Computer science one · Searching) — "The Arrays and Collections classes provide many variations on…

Ideas in this flowchart

  • Arrays and Collections provide many variations of binary-search methods.
  • These methods require the searched array or List to be sorted appropriately.
  • Binary search cannot be used on a Set because it is unordered.
  • The Arrays class provides several binarySearch() methods.
  • There is a binarySearch() variation for each primitive type.
  • Some variations search within a specified range of elements.
  • The most generally useful version is introduced next.
Feed/

What are the requirements for using binary search in Java?

No cover

Channel

Computer science one

1 page

"The Arrays and Collections classes provide many variations on methods that implement binary search. All of these methods assume that the array or List being searched are sorted appropriately (you cannot use binary search on a Set as it is an unordered collection). The Arrays class provides several binarySearch() methods, one for each primitive type as well as variations that allow you to search within a specified range of elements. The most generally useful version is as follows:"

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.