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
- Host: GitHub
- URL: https://github.com/leadstar116/swift_binary_search_algorithm
- Owner: leadstar116
- Created: 2019-12-30T03:55:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-27T14:29:52.000Z (over 5 years ago)
- Last Synced: 2025-03-13T13:13:49.475Z (9 months ago)
- Topics: algorithm, binary-search, swift, swift4
- Language: Swift
- Homepage:
- Size: 53.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.