Skip to content

Commit 68d4905

Browse files
committed
update
1 parent 3f7be55 commit 68d4905

5 files changed

Lines changed: 24 additions & 28 deletions

File tree

DataStructures/Linked List/Algorithms_toDo.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Algorithms ToDo
22

3-
+ linked list
43
+ double linked list
54
+ is palindrome
65
+ sqap nodes

Maths/fibonacci.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
n = 10
1+
function fibonacci(n) {
2+
var a = 0, b = 1, temp = 1;
3+
for (let i = 2; i <= n; i++) {
4+
temp = a + b;
5+
a = b;
6+
b = temp;
7+
console.log(temp);
8+
}
9+
return temp;
10+
}
211

3-
f = [n]
4-
f[0] = 0
5-
f[1] = 1
6-
for(var i = 2; i <= 10; i++)
7-
f[i] = f[i-2]+f[i-1];
8-
9-
10-
for(var i = 0; i <= 10; i++)
11-
console.log(f[i])
12+
fibonacci(7);

NumberConvertions/DecimalToBinary.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

SearchAlgorithms/binarySearch.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
function binarySearch(arr, target) {
2-
let left = 0;
3-
let right = arr.length - 1;
4-
while (left <= right) {
5-
const mid = left + Math.floor((right - left) / 2);
6-
if (arr[mid] === target) {
7-
return mid;
8-
}
9-
if (arr[mid] < target) {
10-
left = mid + 1;
1+
function binarySearch(sortedArray, elementToFind) {
2+
var lowIndex = 0;
3+
var highIndex = sortedArray.length - 1;
4+
while (lowIndex <= highIndex) {
5+
var midIndex = Math.floor((lowIndex + highIndex) / 2);
6+
if (sortedArray[midIndex] == elementToFind) {
7+
return midIndex;
8+
} else if (sortedArray[midIndex] < elementToFind) {
9+
lowIndex = midIndex + 1;
1110
} else {
12-
right = mid - 1;
11+
highIndex = midIndex - 1;
1312
}
14-
}
15-
return -1;
16-
}
13+
} return null;
14+
}

Strings/Algorithms_toDo.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
+ knutz morris pratt
55
+ levenshtein distance
66
+ manacher
7-
+ min cost string conversion
8-
+ rabin karp
7+
+ min cost string conversion

0 commit comments

Comments
 (0)