This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This gist contains implementations of: | |
1. Breadth first search | |
2. Depth first search | |
3. Dijkstra search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In this gist we have | |
1. Insertion sort algorithm | |
2. Heap sort algorithm | |
3. Quick sort algorithm | |
4. Merge sort algorithm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onInputChange = e => { | |
this.setState({ | |
[e.target.name]: e.target.value | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Deletes keys with no data ES 6 | |
Object.keys(data).forEach(key => data[key] === null && delete data[key]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const key = 'DYNAMIC_KEY', | |
obj = { | |
[key]: 'ES6!' | |
}; | |
console.log(obj); | |
// > { 'DYNAMIC_KEY': 'ES6!' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const binarySearch = (arr, target) => { | |
let left = 0; | |
let right = arr.length - 1; | |
while (left <= right) { | |
const mid = left + Math.floor((right - left) / 2); | |
if (arr[mid] === target) { | |
return mid; | |
} | |
if (arr[mid] < target) { | |
left = mid + 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const linearSearch = (array, target) => { | |
for(let i = 0; i < array.length; i++){ | |
if(array[i] === target) return i; | |
} | |
return -1; | |
} |