id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

binarySearch_array


Given an integer array and a target value, use the binary search algorithm to return the index where that value appears in the data set. Return -1 if the value does not exist. Note: The integer array is already sorted from least to greatest and you must use binary search to receive credit for this problem.


binarySearch_array([1, 3, 5], 1) → 0
binarySearch_array([1, 3, 5], 3) → 1
binarySearch_array([1, 3, 5], 5) → 2

...Save, Compile, Run (ctrl-enter)

public int binarySearch_array(int[] arr, int value) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy