Skip to content
/ algo Public

Mastering data structures and algorithms using javascript

License

Notifications You must be signed in to change notification settings

tsq/algo

Repository files navigation

About

Build Status

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
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 ⭐ ⭐ ⭐

Data Structure

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 ⭐ ⭐ ⭐ ⭐ ⭐

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

  1. Add a debugger statement in your function
  2. Call the function manually
  3. At the terminal, run node inspect index.js
  4. To continue execution of the file, press c then enter
  5. To lanch a repl session, type repl then enter
  6. 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 !!!

LICENSE

MIT

About

Mastering data structures and algorithms using javascript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published