About
mastering data structures and algorithms using javascript
Check
npm install && npm test
Algorithms
A process or set of rules to be followed in calculations or other problem-solving operations
Question | Difficulty |
---|---|
String Reversal | :star: |
Paldinromes | :star: |
Integer Reversal | :star: |
MaxChars | :star: |
The Classic FizzBuzz | :star: |
Array Chunking | :star: :star: |
Anagrams | :star: :star: |
Sentence Capitalization | :star: |
Printing Steps | :star: :star: |
Two Sided Steps - Pyramids | :star: :star: :star: |
Find The Vowels | :star: |
Enter the Matrix Spiral | :star: :star: :star: :star: |
Fibonacci | :star: :star: :star: |
Data Structure
Ways of organizing information with optimal runtime complexity for adding or removing records.
Question | Difficulty |
---|---|
The Queue | :star: |
Underwater Queue Weaving | :star: :star: :star: |
The Stack | :star: |
Queue from Stack | :star: :star: :star: |
Linked Lists | :star: :star: :star: :star: :star: |
Back to Javascript - Events | :star: :star: :star: |
Find the Midpoint | :star: :star: :star: :star: |
Circular Lists | :star: :star: :star: :star: |
Step Back From teh Tail | :star: :star: :star: :star: |
Building a Tree | :star: :star: :star: :star: |
Tree Width with Level Width | :star: :star: :star: :star: |
Binary Search Trees | :star: :star: :star: :star: |
Validating a Binary Search Tree | :star: :star: :star: :star: :star: |
Sorting: Bubble, Select, and Merge | :star: :star: :star: :star: :star: |
Runtime complexity
Describes the performance of an algorithm.
Name | Expresion | Description |
---|---|---|
Constant Time | 1 |
No matter how many elements we’re working with, the algorithm/operation/whatever will always take the same amount of time |
Logarithmic Time | log(n) |
You have this if doubling the number of elements you are iterating over doesn’t double the amount of work. Always assume that searching operations are log(n) |
Linear Time | n |
Iterating through all elements in a collection of data. If you see a for loop spanning from ‘0’ to ‘array.length’, you probably have ‘n’, or linear runtime |
Quasilinear Time | n * log(n) |
You have this if doubling the number of elements you are iterating over doesn’t double the amount of work. Always assume that any sorting operating is n*log(n) |
Quadratic Time | n^2 |
Every element in a collection has to be compared to every other element. The handshake problem |
Exponential Time | 2^n |
If you add a ‘single’ element to a collection, the processing power required doubles. |
Big O Notation
O(n) -> Linear
O(1) -> Constant
O(n^2) -> Quadratic
Identifying Runtime Complexity
Iterating with a simple for loop through a single collection -> Probably O(n)
Iterating through half a collection -> Still O(n)
Iterating through two diff collections with separate for loops -> O(n+m)
Two nested for loops iterating over the same collection -> O(n^2)
Two nested for loops iterating over the diff collection -> O(n*m)
Sorting -> O(n*log(n))
Seaching a sorted array? -> O(log(n))
Note: Space Complexity is a thing too.
Debug
- Add a
debugger
statement in your function - Call the function manually
- At the terminal, run
node inspect index.js
- To continue execution of the file, press
c
thenenter
- To lanch a
repl
session, typerepl
thenenter
- To exit the
repl
, press Control + C
Online coding
Thank you https://repl.it! The very cool tool for learning programming language.
So, try and try !!!