elraphty / jsAlgorithms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BASIC JS ALGORITHMS

ALGORITHMS COVERED

  • fizzbuzz
  • isPalindrome
  • binarySearch
  • caeserCipher
  • bubbleSort
  • fibonacci
  • harmlessRansomeNote
  • meanMedianMode
  • memoizedFibonnaci
  • twosum
  • sieve
  • reverseWords
  • reverseArrayPlace
Fizz Buzz Fizz buzz returns fizz when the number is divisible by 3,buzz when the number is divisible by 5 and fizz Buzz when it is divisible by 15, its a common javascript algorithm you can also achieve this functionality with any given sets of number 3, 5 and 15 is not a constant.
Is Palindrome isPalindrome is a function that returns true if a given number of words is the same when reversed e.g madam i'm adam when reversed it gives u the same word.
Binary Search Binary Search is a very popular algorithm is the most efficient algorithm for searching a given set of data, Binary search is a Logarithmic Runtime Big O Notation "0 (log n)", it can be implemented with a recursive function, or a while loop, this example i made use of a recursive function (you can check the bigONotation.js file for a binarySearch implemented with a while loop), so what binary search does is it searches for a key in a given set of data it starts from the middle of a sorted data if the key is the middle element in the dataset it returns else if they key is greater than the middle element is splices the array into two forget about the lower part of the array and search the upper part of the array and vise versa if the key is lesser than the middle element, it returns -1 if the key is not found.
Caeser Cipher Ceaser cipher is an algorithm that takes a given string and a number and shift each letter in the string by the given number passed.
Bubble Sort Bubble sort is a popular sorting algorithm that properly sorts an array in ascending order using Exponential Runtime Big O Notation "0 (n ^ 2).
Fibonacci Fibonacci is an algorithm that returns a sequence of numbers the first two numbers are 1 then every other number after that is the sum of the two previoues numbers e.g 1 1 2 3 5 8 13 21 34 55 89 ..... so in this example we want to check for the number at a given position.
Harmless Ransome Note Harmless ransome note is an algorithm, that take in a checks if a a list of words in a string is present in another string and also present in the right proportion.

About


Languages

Language:JavaScript 100.0%