|
1 |
| -# javascript-algorithms |
2 |
| -✨ Algorithms in JavaScript |
| 1 | + # Common Algorithms in JavaScript |
| 2 | + |
| 3 | + |
| 4 | +#### What's an algorithm? |
| 5 | + |
| 6 | +> An algorithm is a set of instruction to solve problems. |
| 7 | +
|
| 8 | +Still confused? [Watch the video](https://www.youtube.com/watch?v=6hfOvs8pY1k) |
| 9 | +of Professor David J. Malan explains how algorithms can be used in seemingly |
| 10 | +simple situations and also complex ones. |
| 11 | + |
| 12 | +#### List of common algorithms |
| 13 | + |
| 14 | +* [Fizz Buzz](src/fizzbuzz.js) |
| 15 | + |
| 16 | +Fizz-Buzz is a group word game for children to teach them about division. |
| 17 | +Players take turns to count incrementally, replacing any multiple of three |
| 18 | +with the word "fizz", and any multiple of five with the word "buzz". |
| 19 | + |
| 20 | +* [Two Sum](src/TwoSum.js) |
| 21 | + |
| 22 | +You are given an array of n integers and a number k. Determine whether there is a pair |
| 23 | +of elements in the array that sums to exactly k. For example, given the array [1, 3, 7] and |
| 24 | +k = 8, the answer is "yes" but given k = 6 the answer is "no" |
| 25 | + |
| 26 | +* [Harmless Ransom Note](src/HarmlessRansomNote.js) |
| 27 | + |
| 28 | +The harmless ransom note is simply a note made of words cut out from a magazine text. |
| 29 | + |
| 30 | +You have been given two strings. You have to find out whether you can make up the |
| 31 | +first string with the words present in the second string. |
| 32 | + |
| 33 | +* [Is Palindrome](src/IsPalindrome.js) |
| 34 | + |
| 35 | +A palindrome is a word, phrase, number or sequence of words that reads the same backward |
| 36 | +as forward. Punctuation and spaces between the words or lettering is allowed. |
| 37 | + |
| 38 | +* [Caesar Cipher](src/CaesarCipher.js) |
| 39 | + |
| 40 | +Caesar cipher is to replace each plaintext letter with a different one a fixed number of |
| 41 | +places down the alphabet. The cipher illustrated here uses a left shift of three, so that |
| 42 | +(for example) each occurrence of E in the plaintext becomes B in the ciphertext. |
| 43 | + |
| 44 | +* [Reverse Words](src/ReverseWords.js) |
| 45 | + |
| 46 | +Reverse the string without using array.prototype.reverse(). |
| 47 | + |
| 48 | +* [Reverse Array In Place](src/ReverseArrayInPlace.js) |
| 49 | + |
| 50 | +Reverse the order of the elements of an array. |
| 51 | + |
| 52 | +* [Mean Median Mode](src/MeanMedianMode.js) |
| 53 | + |
| 54 | +Calculate the mean, median, or mode of a data set! |
| 55 | + |
| 56 | +* [Fibonacci](src/Fibonacci.js) |
| 57 | + |
| 58 | +The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, . . . |
| 59 | +Each subsequent number is the sum of the previous two. |
| 60 | + |
| 61 | +Write a function to return an n element in Fibonacci sequence |
| 62 | + |
| 63 | +* [Sieve of Eratosthenes](src/SieveOfEratosthenes.js) |
| 64 | + |
| 65 | +In mathematics, the sieve of Eratosthenes is an ancient algorithm for finding all prime |
| 66 | +numbers up to any given limit. It does so by iteratively marking as composite (i.e., |
| 67 | +not prime) the multiples of each prime, starting with the first prime number, 2. |
| 68 | + |
| 69 | +Given a number n, print all primes smaller than or equal to n. It is also given that n |
| 70 | +is a small number. |
| 71 | + |
| 72 | +* [Max Stock Profit](src/MaxStockProfit.js) |
| 73 | + |
| 74 | +Given an array of stock prices over time, need to figure out the best buy and sell price |
| 75 | +so that we get the maximum profit. The selling should occur after buying of the stock. |
| 76 | + |
| 77 | + |
| 78 | +* Plurality (winner take all) |
| 79 | + |
| 80 | +In the plurality vote, every voter gets to vote for one candidate. At the end |
| 81 | +of the election, whichever candidate has the greatest number of votes is |
| 82 | +declared the winner of the election. |
| 83 | + |
| 84 | +* Runoff |
| 85 | + |
| 86 | +In a ranked-choice system, voters can vote for more than one candidate. Instead |
| 87 | +of just voting for their top choice, they can rank the candidates in order of |
| 88 | +preference. |
| 89 | + |
| 90 | +* Readability |
| 91 | +* Liner Search |
| 92 | +* Binary Search |
| 93 | +* Bubble Sort |
| 94 | +* Selection Sort |
| 95 | +* Insertion Sort |
| 96 | +* Recursion |
| 97 | +* Merge Sort |
0 commit comments