Back to Freecodecamp

Step 1

curriculum/challenges/english/blocks/workshop-binary-search/683ec39565dbc7e3375263b1.md

latest1.1 KB
Original Source

--description--

In a previous lesson, you learned about binary search and how it differs from linear search.

In this workshop, you will put that into practice by building a binary search algorithm.

To begin, create a binary_search function with a search_list and value parameters.

search_list is the list of elements the function will search within, and value is the target the function will try to find within the search_list.

Add the pass keyword inside the function for now so the test can pass.

--hints--

You should create a binary_search function.

js
({ 
  test: () => assert(runPython(`_Node(_code).has_function("binary_search")`)) 
})

Your binary_search function should have a search_list and value parameters.

js
({ 
  test: () => assert(
    runPython(
      `_Node(_code).find_function("binary_search").has_args("search_list, value") or _Node(_code).find_function("binary_search").has_args("value, search_list")`
    )
  ) 
})

--seed--

--seed-contents--

py
--fcc-editable-region--

--fcc-editable-region--