[algo] binarySearch
parent
8f886d1336
commit
5e1cc1b0ef
@ -0,0 +1,14 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { binarySearch } from "./binarySearch";
|
||||||
|
|
||||||
|
describe("binarySearch", () => {
|
||||||
|
let sortedArray = [-12, 1, 4, 6, 22];
|
||||||
|
|
||||||
|
it("binarySearch should return index 2", () => {
|
||||||
|
expect(binarySearch(sortedArray, 4)).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("binarySearch not find number 3 should return -1", () => {
|
||||||
|
expect(binarySearch(sortedArray, 3)).toBe(-1);
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1 @@
|
|||||||
|
export * from "./binarySearch";
|
||||||
Loading…
Reference in New Issue