adds bubble sort
This commit is contained in:
12
ts/linear_search.test.ts
Normal file
12
ts/linear_search.test.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
function linear_search(haystack: number[], needle: number): boolean {
|
||||
for (let i = 0; i < haystack.length; i++) {
|
||||
if (haystack[i] === needle) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
test("test linear search", () => {
|
||||
expect(linear_search([1, 2, 3, 4, 5], 3)).toBe(true);
|
||||
})
|
||||
Reference in New Issue
Block a user