Skip to content

Instantly share code, notes, and snippets.

View elitenomad's full-sized avatar
🎯
Focusing

Pranava S Balugari elitenomad

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am elitenomad on github.
  • I am elitenomad (https://keybase.io/elitenomad) on keybase.
  • I have a public key whose fingerprint is 6803 769F 8D8B 79CF F5AE 46F2 5FDA 3049 AFF8 B453

To claim this, I am signing this object:

@elitenomad
elitenomad / bubble_sort.js
Created June 26, 2018 11:53
Bubble sort Javascript implementation: O(n^2)
const bubble_sort = (array) => {
for(let i = 0 ; i < array.length - 1 ; i++) {
for(let j = 0; j < array.length - i - 1; j++){
if(array[j] > array[j + 1]){
const temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
@elitenomad
elitenomad / binary_search.js
Created June 20, 2018 11:35
Javascript Binary search Implementation
const binary_search = (list, item) => {
let min = 0;
let max = list.length - 1;
let middle_index = Math.floor((min + max)/2);
while(min <= max){
if(list[middle_index] == item) {
return list[middle_index];
}
@elitenomad
elitenomad / factorialWithMemoization.js
Created June 20, 2018 10:28
factorial with Memoization
const factorialRecursiveWithMemoization = (n) => {
const multiplyer = (ender) => {
if(ender == 1){
return ender;
}else{
return (ender * multiplyer(ender - 1))
}
}
return multiplyer(n);
@elitenomad
elitenomad / factorial.js
Created June 20, 2018 10:20
Factorial (Recursive and Regular loop methods)
const factorialWithRecursive = (n) => {
if(n == 1){
return n;
}else{
return (n * factorialWithRecursive(n - 1));
}
}
const factorialRecursive = factorialWithRecursive(5);
console.log(`What is factorialRecursive ${factorialRecursive}`);
@elitenomad
elitenomad / joinElements.js
Last active June 20, 2018 10:21
Join elements of an array given a delimiter (Recursive and Regular loop methods)
const joinElements = (array, joiner) => {
const recurse = (index, resultSoFor = '') => {
resultSoFor += array[index];
if (index == array.length - 1) {
return resultSoFor;
} else {
resultSoFor = resultSoFor + joiner;
return recurse(index + 1, resultSoFor);
}