Skip to content

revature-curriculum/binary-search-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lab Instructions

Here we will be constructing our own binary search . Use the search() method given to you and fill in your logic for a Binary Search.

Your parameters for this method will be int [] A, which represents the array given, and int N, which represents the value of an index within the array.

Your method should return one of the following scenarios:

  • If the element exists, return the index of the element.
  • If the element does not exist, return -1.

input -> [-5, -4, -3, -2, -1, 0, 1, 1, 2, 72], -4 output -> 1

input -> [-5, -4, -3, -2, -1, 0, 1, 1, 2, 72], 36 output -> "The element does not exist in the array"

Be sure to be mindful of the array indices as ArrayIndexOutOfBoundsExceptions are very common.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published