Skip to content

Instantly share code, notes, and snippets.

View aanchirinah's full-sized avatar
🎯
Focusing

Audax aanchirinah

🎯
Focusing
  • Andela
  • Lagos
View GitHub Profile
@aanchirinah
aanchirinah / Searching-algorithms.txt
Last active August 28, 2019 00:11
Searching Algorithms
This gist contains implementations of:
1. Breadth first search
2. Depth first search
3. Dijkstra search
@aanchirinah
aanchirinah / Sorting-Algorithms.txt
Last active August 27, 2019 18:26
Sorting Algorithms
In this gist we have
1. Insertion sort algorithm
2. Heap sort algorithm
3. Quick sort algorithm
4. Merge sort algorithm
@aanchirinah
aanchirinah / onChange.js
Last active February 11, 2019 22:09
Handle Multiple inputs with one onChange Handler
onInputChange = e => {
this.setState({
[e.target.name]: e.target.value
});
};
@aanchirinah
aanchirinah / delete-obj-keys.js
Created December 20, 2018 01:00
Deletes keys with no data
// Deletes keys with no data ES 6
Object.keys(data).forEach(key => data[key] === null && delete data[key]);
@aanchirinah
aanchirinah / obj-key.js
Created December 20, 2018 00:56
Dynamic Object Keys
const key = 'DYNAMIC_KEY',
obj = {
[key]: 'ES6!'
};
console.log(obj);
// > { 'DYNAMIC_KEY': 'ES6!' }
@aanchirinah
aanchirinah / binary_search.js
Created November 13, 2018 08:54
Binary search algorithm
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;
@aanchirinah
aanchirinah / linear_search.js
Created November 13, 2018 08:39
Linear Search Algorithm
const linearSearch = (array, target) => {
for(let i = 0; i < array.length; i++){
if(array[i] === target) return i;
}
return -1;
}