Skip to content
/ Algo-cast Public template

Algorithm and Data structure Questions with Multiple Answers in Pure javascript

License

Notifications You must be signed in to change notification settings

vivekdogra02/Algo-cast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Algo-Cast

It is a great learning project where you will find out various algo-problems having multiple different solutions in your favorite language (Javascript).

Algorithms and Data structure with interview questions

If you want to contribute, will be highly appreciated. PRs accepted. Contributor must update the README.md with every PR, with some brief overview of the problem and solutions.

Here are list of Algo problems and solutions :

a.) Quick Find b.) Quick Union c.) Weighted Quick Union d.) Path Compression Union Improvement

12. Chunk

16. Matrix

24. Steps

27. Vowels

Reversing-Questions

Searching-Algorithrms

Sorting-Algorithrms

First two are divide and conquer

Graph

DP

Linked List

LeetCode questions

Space Complexity - Auxiliary space

means the space taken by the whole algorithm, not the space taken up by the inputs

1. Most primitive number( booleans, undefined,numbers, null) have O(1) constant space

2. String requires O(n) space (where n is length of the string)

3. Array and objects ( reference types) requires O(n) space (where for array n is length, number of keys for objects)

Best to Worse case performance measurement

1. O(1) - Constant - BEST

2. O(log n) - Searching Algorithm have this, Efficient Sorthing Algorithm have this & Recursion some time have space complexity in log

3. O(n)

1. O(n log(n))

1. O(n2/n3) etc- Worse

When to use objects

  1. When you don't need order.
  2. When you need fast access/insertion and removal

Big(O) of objects

  1. Insertion - O(1)
  2. Removal - O(1)
  3. Searching - O(N)
  4. Access - O(1)

Big(O) of objects methods

  1. Object.keys - O(N)
  2. Object.values - O(N)
  3. Object.entries - O(N)
  4. Object.hasOwnProperty - O(1)

When to use Arrays

  1. When you need order.
  2. When you need fast access/insertion and removal

Big(O) of Arrays

  1. Insertion - It depends
  2. Removal - It depends
  3. Searching - O(N)
  4. Access - O(1)

Big(O) of Array methods

  1. push - O(1)
  2. pop - O(1)
  3. shift - O(N)
  4. unshift - O(N)
  5. concat - O(N)
  6. slice - O(N)
  7. splice - O(N)
  8. sort - O(n log n)
  9. foreach/map/filter/reduce etc - O(N)