An open API service indexing awesome lists of open source software.

https://github.com/leadstar116/swift_binary_search_algorithm

Implement binary search algorithm in swift
https://github.com/leadstar116/swift_binary_search_algorithm

algorithm binary-search swift swift4

Last synced: 6 months ago
JSON representation

Implement binary search algorithm in swift

Awesome Lists containing this project

README

          

# Description
Implement binary search algorithm in swift

Basic knowledge for binary search:


Binary search works on sorted arrays.


Binary search begins by comparing an element in the middle of the array with the target value.


If the target value matches the element, its position in the array is returned.


If the target value is less than the element, the search continues in the lower half of the array.


If the target value is greater than the element, the search continues in the upper half of the array.


By doing this, the algorithm eliminates the half in which the target value cannot lie in each iteration.