Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Challenge Summary

array binary search

Challenge Description

Write a function called BinarySearch which takes in 2 parameters: a sorted array and the search key. Without utilizing any of the built-in methods available to your language, return the index of the array’s element that is equal to the search key, or -1 if the element does not exist.

Approach & Efficiency

Solution

array binary search whiteboard image

Code Challenge Binary search in a sorted 1D array

Feature Tasks

Write a function called BinarySearch which takes in 2 parameters: a sorted array and the search key. Without utilizing any of the built-in methods available to your language, return the index of the array’s element that is equal to the search key, or -1 if the element does not exist.

NOTE: The search algorithm used in your function should be a binary search. Check the Resources section for details Example

[4,8,15,16,23,42], 15	2
[11,22,33,44,55,66,77], 90	-1

array binary search video

Resources Wikipedia: Binary Search Algorithm

Stretch Goal Once you’ve achieved a working solution, benchmark with varying array sizes (100, 10000, 100000 elements)

Requirements Ensure your complete solution follows the standard requirements.

Write unit tests Follow the template for a well-formatted README Submit the assignment following these instructions