You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-44
Original file line number
Diff line number
Diff line change
@@ -90,16 +90,16 @@ Example:
90
90
91
91
## What you should prepare?
92
92
93
-
-[] Computer Science Concepts
94
-
-[] DataStructure
95
-
-[] Algorithms
93
+
-[] Computer Science Concepts
94
+
-[] DataStructure
95
+
-[] Algorithms
96
96
97
97
## Computer Science Concepts
98
98
99
-
-[] Big O Time
100
-
-[] Big O Space
101
-
-[] Recursion
102
-
-[] Memoization / Dynamic Programming
99
+
-[] Big O Time
100
+
-[] Big O Space
101
+
-[] Recursion
102
+
-[] Memoization / Dynamic Programming
103
103
104
104
## Big O complexity
105
105
@@ -163,7 +163,7 @@ Given a large array of integers and a window of size w, find the current maximum
163
163
164
164
Linked lists are dynamic data structure and memory is allocated at run time. They don't store data contiguously rather they use link to point to other elements.
165
165
166
-

166
+

167
167
168
168
Performance wise linked lists are slower than arrays because there is no direct access to linked list elements.
169
169
@@ -173,7 +173,7 @@ You have to copy 1,2 in new array then insert 3 and copy rest of the values. Run
173
173
174
174
Therefore, we use linked list to store 1-6 and we can easily insert 3 in between 2 and 4.
175
175
176
-

176
+

177
177
178
178
The linked list is a list of items, called nodes. Nodes have two parts, `value` part and `link` part. Value part is used to stores the data. The link part is a reference, which is used to store addresses of the next element in the list.
179
179
@@ -182,9 +182,9 @@ The linked list is a list of items, called nodes. Nodes have two parts, `value`
182
182
-**Value**: The data that is stored in each node of the linked list.
183
183
-**Link**: Link part of the node is used to store the reference of other node.
184
184
185
-

185
+

186
186
187
-

187
+

188
188
189
189
```ts
190
190
classLinkedListNode {
@@ -201,31 +201,31 @@ Below are the types of LinkedList:
201
201
-**Doubly Linked List**
202
202
-**Circular Linked List**
203
203
204
-

204
+

205
205
206
206
#### Insert at head
207
207
208
208
The newly created node will become head of the linked list. · Size of the list is increased by one.
209
209
210
-

210
+

211
211
212
212
#### Insert at tail
213
213
214
-

214
+

215
215
216
216
#### Reverse a Singly Linked List
217
217
218
218
We’re given the pointer/reference to the head of a singly linked list, reverse it and return the pointer/reference to the head of the reversed linked list.
219
219
220
-

220
+

221
221
222
222
Problem Solving steps
223
223
224
-

224
+

225
225
226
226
Running program output
227
227
228
-

228
+

229
229
230
230
### Stack
231
231
@@ -238,7 +238,7 @@ var stack = [1, 2, 3, 4];
238
238
stack.pop(); // 4 , stack [1,2,3]
239
239
stack.pop(); // 3 , stack [1,2]
240
240
stack.pop(); // 2 , stack [1]
241
-
stack.pop(); // 1 , stack []
241
+
stack.pop(); // 1 , stack []
242
242
```
243
243
244
244
### Queue
@@ -248,7 +248,7 @@ Breadth First Search (BFS) uses a `queue` for storing the nodes that it is visit
248
248
#### Enqueue an element in Queue
249
249
250
250
```ts
251
-
var queue = [];
251
+
var queue = [];
252
252
253
253
queue.push(1); // queue [1]
254
254
queue.push(2); // queue [1,2]
@@ -262,7 +262,7 @@ var queue = [1, 2, 3, 4];
262
262
queue.shift(); // 1 , queue [2,3,4]
263
263
queue.shift(); // 2 , queue [3,4]
264
264
queue.shift(); // 3 , queue [4]
265
-
queue.shift(); // 4 , queue []
265
+
queue.shift(); // 4 , queue []
266
266
```
267
267
268
268
### Tree
@@ -271,7 +271,7 @@ A tree has hierarchical data and it has nodes. It is a type of graph. Each node
271
271
A tree is `acyclic` meaning it has no cycles: "a cycle is a path [AKA sequence] of edges and vertices wherein a vertex is reachable from itself".
272
272
Therefore, a tree is also called as `Directed Acyclic Graph (DAG)`.
273
273
274
-

274
+

275
275
276
276
-**Root**: top node of tree is called root and has no parent and has no incoming edges.
277
277
-**Node**: every node has parent ( except root ) and 0 or more children's.
@@ -284,9 +284,9 @@ Therefore, a tree is also called as `Directed Acyclic Graph (DAG)`.
284
284
-**Parent**: Node is a parent of all the child nodes that are linked by outgoing edges. - **Sibling**: Nodes in the tree that are children of the same parent are called siblings.
285
285
-**Ancestor**: A node reachable by repeated moving from child to parent.
286
286
287
-

287
+

288
288
289
-

289
+

290
290
291
291
If you want to store hierarchical data use Tree.
292
292
@@ -296,7 +296,7 @@ You should know about `Binary Tree` and `Binary Search Tree`.
296
296
297
297
In BFS algorithm, a graph is traversed in layer-by-layer fashion. point. The queue is used to implement BFS.
298
298
299
-

299
+

300
300
301
301
Example: Suppose you have given a tree structure and asked to calculate the average of numbers at each level.
302
302
@@ -305,7 +305,7 @@ Example: Suppose you have given a tree structure and asked to calculate the aver
@@ -314,14 +314,14 @@ Example: Suppose you have given a tree structure and asked to calculate the aver
314
314
315
315
The DFS algorithm we start from starting point and go into depth of graph until we reach a dead end and then move up to parent node (Backtrack). The stack is used to implement DFS.
@@ -340,7 +340,7 @@ The DFS algorithm we start from starting point and go into depth of graph until
340
340
341
341
A binary tree is a type of tree in which each node has `at most two children` (0, 1 or 2) which are referred as left child and right child.
342
342
343
-

343
+

344
344
345
345
#### Binary Search Tree (BST)
346
346
@@ -349,15 +349,15 @@ In Binary Search Tree nodes are:
349
349
- The key in the left subtree is less than the key in its parent node.
350
350
- The key in the right subtree is greater or equal the key in its parent node.
351
351
352
-

352
+

353
353
354
354
[Checkout Binary Search Tree Visualization here.](https://www.cs.usfca.edu/~galles/visualization/BST.html)
355
355
356
356
BSTs get an average case of `O(log n)` on gets, adds, and deletes, but they can have a worst case of `O(n)` if you do something like add a sorted list to a BST. Go ahead, do a BST then add [1,2,3,4,5] to it.
357
357
358
358
Below image showing how to add `[3, 7, 4, 6, 5, 1, 10, 2, 9, 8]` in BST.
359
359
360
-

360
+

361
361
362
362
-[Binary Search Tree Implementation Question](https://codepen.io/roopkt/pen/RwpJBOw?editors=0010)
363
363
-[Binary Search Tree Implementation Answer](https://codepen.io/roopkt/pen/LYWBYMM?editors=0010)
@@ -366,15 +366,15 @@ Below image showing how to add `[3, 7, 4, 6, 5, 1, 10, 2, 9, 8]` in BST.
366
366
367
367
Trie is a tree, in which we store only one character at each node. This final key value pair is stored in the leaves.
368
368
369
-

369
+

370
370
371
371
Trie is also suitable for solving partial match and range query problems.
372
372
373
373
### Heap ( Priority Queue )
374
374
375
375
Each node in the heap follows the rule that the `parent value is greater than its two children` are.
376
376
377
-

377
+

378
378
379
379
There are two types of the heap data structure:
380
380
@@ -389,13 +389,13 @@ It is just like a dictionary or key value pair.
389
389
390
390
### Graph
391
391
392
-

392
+

393
393
394
394
Graph represents network. It has Nodes, Vertices and Edges.
0 commit comments