mastering data structures and algorithms using javascript
npm install && npm test
A process or set of rules to be followed in calculations or other problem-solving operations
Question | Difficulty |
---|---|
String Reversal | ⭐ |
Paldinromes | ⭐ |
Integer Reversal | ⭐ |
MaxChars | ⭐ |
The Classic FizzBuzz | ⭐ |
Array Chunking | ⭐ ⭐ |
Anagrams | ⭐ ⭐ |
Sentence Capitalization | ⭐ |
Printing Steps | ⭐ ⭐ |
Two Sided Steps - Pyramids | ⭐ ⭐ ⭐ |
Find The Vowels | ⭐ |
Enter the Matrix Spiral | ⭐ ⭐ ⭐ ⭐ |
Fibonacci | ⭐ ⭐ ⭐ |
Ways of organizing information with optimal runtime complexity for adding or removing records.
Question | Difficulty |
---|---|
The Queue | ⭐ |
Underwater Queue Weaving | ⭐ ⭐ ⭐ |
The Stack | ⭐ |
Queue from Stack | ⭐ ⭐ ⭐ |
Linked Lists | ⭐ ⭐ ⭐ ⭐ ⭐ |
Back to Javascript - Events | ⭐ ⭐ ⭐ |
Find the Midpoint | ⭐ ⭐ ⭐ ⭐ |
Circular Lists | ⭐ ⭐ ⭐ ⭐ |
Step Back From teh Tail | ⭐ ⭐ ⭐ ⭐ |
Building a Tree | ⭐ ⭐ ⭐ ⭐ |
Tree Width with Level Width | ⭐ ⭐ ⭐ ⭐ |
Binary Search Trees | ⭐ ⭐ ⭐ ⭐ |
Validating a Binary Search Tree | ⭐ ⭐ ⭐ ⭐ ⭐ |
Sorting: Bubble, Select, and Merge | ⭐ ⭐ ⭐ ⭐ ⭐ |
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.
- 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
Thank you https://repl.it! The very cool tool for learning programming language.
So, try and try !!!