binarySearch(A, n, num)
Syntax: [index] = binarySearch(A, n, num);
Inputs: A: Array (sorted) that you want to search
n: Length of array A
num: Number you want to search in array A
Outputs: index: Return position in A that A(index) == num or -1 if num does not exist in A
Complexity: O(1) best-case performance
O(log_2 (n)) worst-case performance
O(1) auxiliary space
Author: Trong Hoang Vo
hoangtrong2305@gmail.com
Date: March 31, 2016
Cite As
Trong Hoang Vo (2026). binarySearch(A, n, num) (https://www.mathworks.com/matlabcentral/fileexchange/56271-binarysearch-a-n-num), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0 |
|
