Skip to content

Commit b029831

Browse files
committed
chore: adding more algo
1 parent 5f868de commit b029831

File tree

6 files changed

+92
-57
lines changed

6 files changed

+92
-57
lines changed

README.md

Lines changed: 92 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
- [What you should prepare?](#what-you-should-prepare)
2-
- [Big O](#big-o)
2+
- [Computer Science Concepts](#computer-science-concepts)
3+
- [Big O Time complexity](#big-o-time-complexity)
4+
- [Big O Space complexity](#big-o-space-complexity)
5+
- [Recursion](#recursion)
36
- [Data Structures you should know](#data-structures-you-should-know)
4-
- [Fundamental algorithms you should know](#fundamental-algorithms-you-should-know)
7+
- [Algorithms you should know](#algorithms-you-should-know)
58
- [Working with this repo](#working-with-this-repo)
6-
- [Math & Stats](#math--stats)
7-
- [Integer Division Without Using \* or /](#integer-division-without-using--or-)
89
- [Mock Interview](#mock-interview)
910
- [Get the Average value at each level of the tree](#get-the-average-value-at-each-level-of-the-tree)
1011
- [ADT](#adt)
@@ -32,13 +33,17 @@
3233
- [Depth-First Search (DFS)](#depth-first-search-dfs)
3334
- [Breadth-First Search (BFS)](#breadth-first-search-bfs)
3435
- [DFS Vs BFS](#dfs-vs-bfs)
35-
- [Sorting](#sorting)
36+
- [Algorithms](#algorithms)
3637
- [Merge Sort](#merge-sort)
3738
- [Merge Sort Algorithm Simulator](#merge-sort-algorithm-simulator)
3839
- [Implement Merge Sort](#implement-merge-sort)
39-
- [Find Median Values](#find-median-values)
40-
- [Math.floor](#mathfloor)
41-
- [Math.round](#mathround)
40+
- [Find Median Values (With Merge Sort Algorithm)](#find-median-values-with-merge-sort-algorithm)
41+
- [BFS (Breath First Search)](#bfs-breath-first-search)
42+
- [Math & Stats](#math--stats)
43+
- [Integer Division Without Using \* or /](#integer-division-without-using--or-)
44+
- [Array slice](#array-slice)
45+
- [Math.floor](#mathfloor)
46+
- [Math.round](#mathround)
4247

4348
### What you should know before coding interview?
4449

@@ -56,48 +61,54 @@ Example:
5661

5762
## What you should prepare?
5863

59-
### Big O
64+
- [] DataStructure
65+
- [] Algorithms
66+
- [] Concepts
67+
68+
### Computer Science Concepts
69+
70+
- [] Big O Time
71+
- [] Big O Space
72+
- [] Recursion
73+
- [] Memoization / Dynamic Programming
74+
75+
#### Big O Time complexity
6076

6177
Learn Big O. Make sure you give what would be the `runtime complexity` and `memory complexity`.
6278

79+
#### Big O Space complexity
80+
6381
`Iterative functions` take no extra memory and therefore, `memory complexity` is `constant` O(1).
6482

6583
`Recursive functions` take extra on the stack therefore, `memory complexity` is `lograrithmic` O(_logn_)
6684

67-
### Data Structures you should know
68-
69-
- Hash Table
70-
- Linked List
71-
- Stack
72-
- Queue
73-
- Tree
74-
- Tries
75-
- Graphs
76-
- Vectors
77-
- Heaps
85+
#### Recursion
7886

79-
### Fundamental algorithms you should know
87+
### Data Structures you should know
8088

81-
- Breadth-first search
82-
- Depth-first search
83-
- Merge sort & Quick sort
89+
- [x] Array
90+
- [] Hash Table
91+
- [x] Linked List
92+
- [] Stack
93+
- [] Queue
94+
- [] Tree
95+
- [] Tries
96+
- [] Graphs
97+
- [] Heaps
98+
- [] Vectors
99+
100+
### Algorithms you should know
101+
102+
- [x] Merge sort
103+
- [] Quick sort
104+
- [] Breadth-first search
105+
- [] Depth-first search
106+
- [x] Binary Search
84107

85108
## Working with this repo
86109

87110
Download or clone in local machine. Then run individual file in node console to see the results.
88111

89-
## Math & Stats
90-
91-
### Integer Division Without Using \* or /
92-
93-
Divide two integers without using '/' (division) or '\*' (multiplication) operators.
94-
95-
```shell
96-
node .\src\math-and-stats\integer-division.js
97-
```
98-
99-
![](https://imgur.com/Cf7cz4W.png)
100-
101112
## Mock Interview
102113

103114
### Get the Average value at each level of the tree
@@ -344,15 +355,18 @@ Example: Suppose you have given a tree structure and asked to calculate the aver
344355
| Uses Stack to sort | Uses Queue to sort |
345356
| Time complexity: Fast | Time complexity: Slow |
346357
| Where to use: if you can find at root or leaf, find connected components. | Where to use: Find shortest path,find connected components. When you think you have less data go for it. |
358+
| Time Complexity: O(V+E) | Time Complexity: O(V+E) |
347359

348-
## Sorting
360+
## Algorithms
349361

350362
### Merge Sort
351363

352364
Browser's JavaScript Engine (`Array.prototype.sort`) uses merge sort maximum time. Runtime complexity O(n logn), Memory complexity O(n) because we have to create new list. It uses divide-and-conquer algorithm! and also it is recursive.
353365

354366
https://www.youtube.com/watch?v=UxnyImctVzg
355367

368+
![](https://i.imgur.com/YpQSB5J.png)
369+
356370
#### Merge Sort Algorithm Simulator
357371

358372
[![Merge Sort Algorithm Simulator](https://img.youtube.com/vi/UxnyImctVzg/0.jpg)](https://www.youtube.com/watch?v=UxnyImctVzg 'Merge Sort Algorithm Simulator')
@@ -361,7 +375,7 @@ https://www.youtube.com/watch?v=UxnyImctVzg
361375

362376
[Exercise File](src/sorting/merge-sort/merge-sort.mjs)
363377

364-
#### Find Median Values
378+
#### Find Median Values (With Merge Sort Algorithm)
365379

366380
2 sorted arrays find the median element. Median is the middle index its not an average of values in an sorted array.
367381

@@ -371,14 +385,46 @@ So in order to find median we can use the stich algorithm since arrays are alrea
371385

372386
[Exercise File](src/sorting/merge-sort/find-median-values.mjs)
373387

374-
## Math.floor
388+
### BFS (Breath First Search)
389+
390+
## Math & Stats
391+
392+
### Integer Division Without Using \* or /
393+
394+
Divide two integers without using '/' (division) or '\*' (multiplication) operators.
395+
396+
```shell
397+
node .\src\math-and-stats\integer-division.js
398+
```
399+
400+
![](https://imgur.com/Cf7cz4W.png)
401+
402+
### Array slice
375403

376-
2.5 = 2
377-
2.8 = 2
378-
2.4 = 2
404+
Slice does not mutate the original array.
405+
`slice(index,count) `: Starts taking number from given index and go till given count.
406+
407+
[Example of slice](https://i.imgur.com/9iaew6W.png):
408+
409+
```js
410+
[20,39,48,58,16,36,48].slice(0,3) = [20,39,48,58]
411+
[20,39,48,58,16,36,48].slice(3,7) = [58,16,36,48]
412+
```
379413

380-
## Math.round
414+
![](https://i.imgur.com/9iaew6W.png)
381415

382-
2.5 = 3
383-
2.8 = 3
384-
2.4 = 2
416+
### Math.floor
417+
418+
```javascript
419+
Math.floor(2.5) = 2
420+
Math.floor(2.8) = 2
421+
Math.floor(2.4) = 2
422+
```
423+
424+
### Math.round
425+
426+
```javascript
427+
Math.round(2.5) = 3
428+
Math.round(2.8) = 3
429+
Math.round(2.4) = 2
430+
```

src/data-structure/5-graph/breadth-first-traversal.mjs

Whitespace-only changes.

src/data-structure/5-trees/breadth-first-traversal.mjs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)