Skip to content

Commit 53f53d0

Browse files
authored
Merge pull request vJechsmayr#119 from LuAnderson/feature/otimized-binary-search
feat(otimized-b-searc): create and otimized binary search algorithm otimized with es6+
2 parents 762fa26 + f10419d commit 53f53d0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//Language: Javascript
2+
//Author: Lucas Anderson Lima
3+
//Github: https://github.com/LuAnderson
4+
5+
const list = [1, 999, 5, 2, 6, 4, 848, 494, 54, 13, 7, 9];
6+
7+
const BinarySearch = (list, numberToSearch) => {
8+
const resultSearch = list.indexOf(numberToSearch);
9+
console.log(resultSearch <= 0 ? numberToSearch + ' is not present' : resultSearch);
10+
}
11+
12+
BinarySearch(list, 54);

0 commit comments

Comments
 (0)