Skip to content

Commit 53e903e

Browse files
committedJun 17, 2019
docs: much nicer readme
1 parent 3a4bad7 commit 53e903e

File tree

2 files changed

+356
-127
lines changed

2 files changed

+356
-127
lines changed
 

‎README.md

Lines changed: 338 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
[![CircleCI](https://img.shields.io/circleci/build/github/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/master.svg)](https://circleci.com/gh/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript) [![NPM version](https://badge.fury.io/js/dsa.js.svg)](https://badge.fury.io/js/dsa.js) [![Slack](https://dsajs-slackin.herokuapp.com/badge.svg)](https://dsajs-slackin.herokuapp.com)
66

7-
> This is the coding implementations of the [DSA.js book](https://books.adrianmejia.com/dsajs-data-structures-algorithms-javascript/).
7+
> This is the coding implementations of the [DSA.js book](https://books.adrianmejia.com/dsajs-data-structures-algorithms-javascript/) and the repo for the [npm package](https://www.npmjs.com/package/dsa.js).
88
9-
> In this repository you can find classical algorithms and data structures implemented and explained in JavaScript. it can be used as a reference manual where developers can refresh specific topics before an interview or looking for ideas to solve a problem optimally.
9+
> In this repository, you can find classical algorithms and data structures implemented and explained in JavaScript. It can be used as a reference manual where developers can refresh specific topics before an interview or looking for ideas to solve a problem more optimally.
1010
1111
<!-- (Check out the Time Complexity Cheatsheet) -->
1212

@@ -24,10 +24,30 @@ https://img.shields.io/github/repo-size/amejiarosario/dsa.js.svg - 98.1 MB
2424
[![Interactive Data Structures](https://user-images.githubusercontent.com/418605/46118890-ba721180-c1d6-11e8-82bc-6a671428b422.png)](https://embed.kumu.io/85f1a4de5fb8430a10a1bf9c5118e015)
2525

2626

27-
## Table of Contents (TODO)
27+
## Table of Contents
2828

29-
<!-- START doctoc -->
30-
<!-- END doctoc -->
29+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
30+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
31+
32+
33+
- [Installation](#installation)
34+
- [Features](#features)
35+
- [What's Inside](#whats-inside)
36+
- [📈 Algorithms Analysis](#-algorithms-analysis)
37+
- [🥞 Linear Data Structures](#-linear-data-structures)
38+
- [🌲 Non-Linear Data Structures](#-non-linear-data-structures)
39+
- [⚒ Algorithms Techniques](#%E2%9A%92-algorithms-techniques)
40+
- [FAQ](#faq)
41+
- [Support](#support)
42+
- [Donations](#donations)
43+
- [License](#license)
44+
- [Book](#book)
45+
- [Data Structures](#data-structures)
46+
- [Linear Data Structures](#linear-data-structures)
47+
- [Non-Linear Data Structures](#non-linear-data-structures)
48+
- [Algorithms](#algorithms)
49+
50+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
3151

3252

3353
## Installation
@@ -49,15 +69,17 @@ For a full list of all the exposed data structures and algorithms [see](https://
4969

5070
## Features
5171

72+
Algorithms are an essential toolbox for every programmer.
73+
74+
You usually need algorithms when you have to sort data, search for a value, transform data, scale your code to many users just to name a few.
75+
Algorithms are just the step you follow to solve a problem while data structures are where you store the data for later manipulation. Both combined create programs.
76+
5277
> Algorithms + Data Structures = Programs.
5378
54-
Algorithms are an essential toolbox for every programmer.
55-
You usually need them when you have to sort data, search for a value, transform data, scale your code to many users and so on.
56-
Algorithms are the step you follow to solve a problem while data structures are where you store the data.
57-
Both combined create programs.
5879
It's true that most programming languages and libraries provides implementations for basic data structures and algorithms.
5980
However, to make use of data structures properly, you have to know the tradeoffs so you can choose the best tool for the job.
60-
That's what you are going to learn here:
81+
82+
This material is going to teach you to:
6183

6284
- 🛠 Apply strategies to tackle algorithm questions. Never to get stuck again. Ace those interviews!
6385
- ✂️ Construct efficient algorithms. Learn how to break down problems in manageable pieces.
@@ -66,187 +88,340 @@ That's what you are going to learn here:
6688

6789
## What's Inside
6890

69-
### 📈 Algorithms Analysis
91+
All the code and explanations are available on this repo. You can dig through the links and code examples from the ([src folder](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/tree/master/src)). However, the inline code examples are not expanded (because of Github's asciidoc limitations) but you can follow the path and see the implementation.
92+
93+
_Note: If you prefer to consume the information in a more linear fashion then the [book format](https://books.adrianmejia.com/dsajs-data-structures-algorithms-javascript/) would be more appropriate for you._
94+
95+
The topics are divided in 4 main categories as you can see below:
7096

71-
- Computer Science nuggets without all the mumbo-jumbo.
97+
_(You can click on the ⯈ to expand the topics)_
98+
99+
### 📈 [Algorithms Analysis](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/part1.adoc)
100+
101+
<!-- - Computer Science nuggets without all the mumbo-jumbo.
72102
- Learn how to compare algorithms using Big O notation.
73-
- 8 examples to explain with code how to calculate time complexity.
103+
- 8 examples to explain with code how to calculate time complexity. -->
74104

75-
### 🥞 Linear Data Structures
105+
<blockquote>
76106

77-
- Understand the ins and outs of the most common data structures.
78-
- When to use an Array or Linked List. Know the tradeoffs.
79-
- Build a Stack and a Queue from scratch.
107+
<details>
108+
<summary>
109+
Computer Science nuggets without all the mumbo-jumbo
110+
</summary>
80111

81-
### 🌲 Non-Linear Data Structures
82-
- Understand how hash maps and sets work.
83-
- Know the properties of Graphs and Trees.
84-
- Implement a binary search tree for fast lookups.
112+
---
85113

86-
### ⚒ Algorithms Techniques
114+
### [Computer Science nuggets without all the mumbo-jumbo](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/algorithms-analysis.adoc)
87115

88-
- Never get stuck solving a problem with 7 simple steps.
89-
- Master the most popular sorting algorithms (mergesort, quicksort, insertion sort, ...)
90-
- Learn different approaches to solve problems such as divide and conquer, dynamic programming, greedy algorithms, and backtracking.
116+
#### Learn to calculate run time from code examples
91117

92-
## FAQ
118+
![Translating lines of code to an approximate number of operations](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/raw/master/book/images/image4.png)
93119

94-
<details>
95-
<summary>How would I apply these to my day-to-day work?</summary>
96-
<p>
97-
As a programmer, we have to solve problems every day. If you want to solve problems well, then it's good to
98-
know about a broad range of solutions. A lot of times, it's more efficient to learn existing resources than
99-
stumble upon the answer yourself. The more tools and practice you have, the better. This book helps you
100-
understand the tradeoffs among data structures and reason about algorithms performance.
101-
</p>
102-
</details>
120+
---
103121

104-
<details>
105-
<summary>Hey OP, why you created this repo/book?</summary>
106-
<p>
107-
There are not many books about Algorithms in JavaScript. This material fills the gap.
108-
Also, it's good practice :)
109-
</p>
110122
</details>
111123

112124
<details>
113-
<summary>Is there anyone I can contact if I have questions about something in particular?
114-
</summary>
115-
<p>
116-
Yes, open an issue or ask questions on the slack channel.
117-
</p>
118-
</details>
125+
<summary>
126+
Learn how to compare algorithms using Big O notation.
127+
</summary>
119128

120-
## Support
129+
---
121130

122-
Reach out to me at one of the following places!
131+
### [Learn how to compare algorithms using Big O notation.](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/big-o-examples.adoc#finding-duplicates-in-an-array-na%C3%AFve-approach)
123132

124-
- Twitter at <a href="http://twitter.com/amejiarosario" target="_blank">`@amejiarosario`</a>
125-
- Slack at <a href="https://dsajs-slackin.herokuapp.com" target="_blank">`dsajs.slack.com`</a>
133+
#### Comparing algorithms using Big O notation
126134

135+
Let's say you want to find the duplicates on an array.
136+
Using Big O notation we can compare different implementations that do exactly the same but
137+
they take different time to complete.
127138

128-
## Donations
139+
- [Optimal solution using a map](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/big-o-examples.adoc#linear-example)
140+
- [Finding duplicates in an array (naïve approach)](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/big-o-examples.adoc#quadratic-example)
129141

130-
The best way to support this project is buying the [book](https://books.adrianmejia.com/dsajs-data-structures-algorithms-javascript/), so I can invest more time into this project and keep improving it.
142+
---
131143

132-
## License
144+
</details>
133145

134-
[![License](https://img.shields.io/:license-mit-blue.svg?style=flat-square)](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/LICENSE)
146+
<details>
147+
<summary>
148+
8 examples to explain with code how to calculate time complexity
149+
</summary>
135150

136151
---
137-
---
138-
---
139152

153+
[8 examples to explain with code how to calculate time complexity](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/big-o-examples.adoc#summary)
140154

141-
## Book
155+
#### Most common time complexities
142156

143-
You can also buy this repo in [book format](https://books.adrianmejia.com/dsajs-data-structures-algorithms-javascript/) that goes deeper into each topic and provide additional illustrations and explanations.
157+
![image](https://user-images.githubusercontent.com/418605/59617342-2a715080-90f4-11e9-9de9-9315fb0133f9.png)
144158

145-
- Algorithmic toolbox to avoid getting stuck while coding.
146-
- Explains data structures similarities and differences.
147-
- Algorithm analysis fundamentals (Big O notation, Time/Space complexity) and examples.
148-
- Time/space complexity cheatsheet.
159+
<!-- - Constant time: _O(1)_
160+
- Logarithmic time: _O(log n)_
161+
- Linear time: _O(n)_
162+
- Linearithmic time: _O(n log n)_
163+
- Quadratic time: _O(n^2^)_
164+
- Cubic time: _O(n^3^)_
165+
- Exponential time: _O(2^n^)_
166+
- Factorial time: _O(n!)_ -->
149167

150-
<a href="https://books.adrianmejia.com/dsajs-data-structures-algorithms-javascript/"><img src="https://user-images.githubusercontent.com/418605/55248546-60ebad80-5220-11e9-8cb5-85923f44e196.png" height="400px" alt="dsajs algorithms javascript book"></a>
168+
#### Time complexity graph
151169

152-
<!--
153-
WARNING: Although you can find the [book text on this repo](https://github.com/amejiarosario/dsa.js/blob/master/book/book.adoc), there are some things that doesn't work well with Github's Asciidoc unfortunately. For instance rendering Graphviz diagrams, internal link references, embedding code into docs and so on. For better reading experience and nicer presentation you can get the [PDF format here](https://books.adrianmejia.com/dsajs-data-structures-algorithms-javascript/).
154-
-->
170+
![Most common time complexities](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/raw/master/book/images/image5.png)
155171

156-
## Data Structures
172+
---
157173

158-
We are covering the following data structures.
174+
</details>
175+
</blockquote>
159176

160-
[![Interactive Data Structures](https://user-images.githubusercontent.com/418605/46118890-ba721180-c1d6-11e8-82bc-6a671428b422.png)](https://embed.kumu.io/85f1a4de5fb8430a10a1bf9c5118e015)
177+
### 🥞 [Linear Data Structures](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/part2.adoc)
178+
179+
<!-- - Understand the ins and outs of the most common data structures.
180+
- When to use an Array or Linked List. Know the tradeoffs.
181+
- Build a Stack and a Queue from scratch. -->
182+
183+
<blockquote>
184+
185+
<details>
186+
<summary>
187+
Understand the ins and outs of the most common data structures.
188+
</summary>
161189

162-
### Linear Data Structures
190+
---
191+
192+
#### [Understand the ins and outs of the most common data structures](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/part2.adoc)
163193

164-
1. **Arrays**: Built-in in most languages so not implemented here. [Array Time complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/array.adoc#array-complexity)
194+
195+
- [Arrays](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/array.adoc): Built-in in most languages so not implemented here. [Array Time complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/array.adoc#array-complexity)
165196
<!-- [Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#Array). -->
166197

167-
2. **Linked Lists**: each data node has a link to the next (and
198+
- [Linked List](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/linked-list.adoc): each data node has a link to the next (and
168199
previous).
169200
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/data-structures/linked-lists/linked-list.js)
170201
|
171202
[Linked List Time Complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/linked-list.adoc#linked-list-complexity-vs-array-complexity)
172203
<!-- [Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#Linked-Lists) -->
173204

174-
3. **Queue**: data flows in a "first-in, first-out" (FIFO) manner.
205+
- [Queue](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/queue.adoc): data flows in a "first-in, first-out" (FIFO) manner.
175206
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/data-structures/queues/queue.js)
176207
|
177208
[Queue Time Complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/queue.adoc#queue-complexity)
178209
<!-- [Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#Queues) -->
179210

180-
4. **Stacks**: data flows in a "last-in, first-out" (LIFO) manner.
211+
- [Stack](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/stack.adoc): data flows in a "last-in, first-out" (LIFO) manner.
181212
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/data-structures/stacks/stack.js)
182213
|
183214
[Stack Time Complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/stack.adoc#stack-complexity)
184215
<!-- [Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#Stacks) -->
185216

186-
### Non-Linear Data Structures
217+
---
218+
219+
</details>
220+
<details>
221+
<summary>
222+
When to use an Array or Linked List. Know the tradeoffs.
223+
</summary>
224+
225+
---
226+
227+
#### [When to use an Array or Linked List. Know the tradeoffs](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/linear-data-structures-outro.adoc)
228+
229+
Use Arrays when…
230+
- You need to access data in random order fast (using an index).
231+
- Your data is multi-dimensional (e.g., matrix, tensor).
232+
233+
Use Linked Lists when:
234+
- You will access your data sequentially.
235+
- You want to save memory and only allocate memory as you need it.
236+
- You want constant time to remove/add from extremes of the list.
237+
238+
---
239+
240+
</details>
241+
<details>
242+
<summary>
243+
Build a List, Stack and a Queue.
244+
</summary>
245+
246+
---
247+
248+
#### [Build a List, Stack and a Queue from scratch](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/part2.adoc)
249+
250+
Build any of these data structures from scratch:
251+
- [Linked List](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/src/data-structures/linked-lists/linked-list.js)
252+
- [Stack](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/src/data-structures/stacks/stack.js)
253+
- [Queue](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/src/data-structures/queues/queue.js)
254+
255+
---
256+
257+
</details>
258+
</blockquote>
259+
260+
### 🌲 [Non-Linear Data Structures](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/part3.adoc)
261+
<!-- - Understand one of the most versatile data structure of all: Maps -->
262+
<!-- - Know the properties of Graphs and Trees. -->
263+
<!-- - Implement a binary search tree for fast lookups. -->
264+
265+
<blockquote>
266+
<details>
267+
<summary>
268+
Understand one of the most versatile data structure of all: Maps
269+
</summary>
270+
271+
---
272+
273+
#### [HashMaps](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/map.adoc)
274+
275+
Learn how to implement different types of Maps such as:
276+
- [HashMap](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/map-hashmap.adoc)
277+
- [TreeMap](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/map-treemap.adoc)
278+
279+
Also, [learn the difference between the different Maps implementations](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/map-hashmap-vs-treemap.adoc):
280+
281+
- `HashMap` is more time-efficient. A `TreeMap` is more space-efficient.
282+
- `TreeMap` search complexity is *O(log n)*, while an optimized `HashMap` is *O(1)* on average.
283+
- `HashMap`’s keys are in insertion order (or random depending in the implementation). `TreeMap`’s keys are always sorted.
284+
- `TreeMap` offers some statistical data for free such as: get minimum, get maximum, median, find ranges of keys. `HashMap` doesn’t.
285+
- `TreeMap` has a guarantee always an *O(log n)*, while `HashMap`s has an amortized time of *O(1)* but in the rare case of a rehash, it would take an *O(n)*.
286+
287+
---
288+
289+
</details>
290+
291+
<details>
292+
<summary>
293+
Know the properties of Graphs and Trees.
294+
</summary>
295+
296+
---
297+
298+
#### [Know the properties of Graphs and Trees](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/part3.adoc)
299+
300+
##### [Graphs](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/graph.adoc)
187301

188-
1. **Trees**: data nodes has zero or more adjacent nodes a.k.a.
302+
Know all the graphs properties with many images and illustrations.
303+
304+
![graph example with USA airports](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/raw/master/book/images/image46.png)
305+
306+
**Graphs**: data **nodes** that can have a connection or **edge** to
307+
zero or more adjacent nodes. Unlike trees, nodes can have multiple
308+
parents, loops.
309+
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/graphs/graph.js)
310+
|
311+
[Graph Time Complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/graph.adoc#graph-complexity)
312+
313+
#### [Trees](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/tree.adoc)
314+
315+
Learn all the different kinds of trees and its properties.
316+
317+
![tree data structure properties](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/raw/master/book/images/image31.jpg)
318+
319+
- **Trees**: data nodes has zero or more adjacent nodes a.k.a.
189320
children. Each node can only have one parent node otherwise is a
190321
graph not a tree.
191322
[Code](https://github.com/amejiarosario/algorithms.js/tree/master/src/data-structures/trees)
192323
|
193324
[Docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/tree.adoc)
194325
<!-- [Post](https://adrianmejia.com/blog/2018/06/11/data-structures-for-beginners-trees-binary-search-tree-tutorial/) -->
195326

196-
1. **Binary Trees**: same as tree but only can have two children at
327+
- **Binary Trees**: same as tree but only can have two children at
197328
most.
198329
[Code](https://github.com/amejiarosario/algorithms.js/tree/master/src/data-structures/trees)
199330
|
200331
[Docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/tree.adoc#binary-tree)
201332
<!-- [Post](https://adrianmejia.com/blog/2018/06/11/data-structures-for-beginners-trees-binary-search-tree-tutorial/#Binary-Trees) -->
202333

203-
2. **Binary Search Trees** (BST): same as binary tree, but the
334+
- **Binary Search Trees** (BST): same as binary tree, but the
204335
nodes value keep this order `left < parent < right`.
205336
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/trees/binary-search-tree.js)
206337
|
207338
[BST Time complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/tree--binary-search-tree.adoc#tree-complexity)
208339
<!-- [Post](https://adrianmejia.com/blog/2018/06/11/data-structures-for-beginners-trees-binary-search-tree-tutorial/#Binary-Search-Tree-BST) -->
209340

210-
3. **AVL Trees**: Self-balanced BST to maximize look up time.
341+
- **AVL Trees**: Self-balanced BST to maximize look up time.
211342
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/trees/avl-tree.js)
212343
|
213344
[AVL Tree docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/tree--avl.adoc)
214345
|
215346
[Self-balancing & tree rotations docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/tree--self-balancing-rotations.adoc)
216347
<!-- [Post](https://adrianmejia.com/blog/2018/07/16/self-balanced-binary-search-trees-with-avl-tree-data-structure-for-beginners/) -->
217348

218-
4. **Red-Black Trees**: Self-balanced BST more loose than AVL to
349+
- **Red-Black Trees**: Self-balanced BST more loose than AVL to
219350
maximize insertion speed.
220351
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/trees/red-black-tree.js)
221352

222-
2. **Maps**: key-value store.
353+
---
223354

224-
1. **Hash Maps**: implements map using a hash function.
225-
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/data-structures/maps/hash-maps/hash-map.js)
226-
|
227-
[HashMap time complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/map-hashmap.adoc#hashmap-time-complexity)
228-
<!-- [Docs](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#HashMaps) -->
229-
<!-- [Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#HashMaps) -->
355+
</details>
230356

231-
2. **Tree Maps**: implement map using a self-balanced BST.
232-
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/data-structures/maps/tree-maps/tree-map.js)
233-
|
234-
[TreeMap docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/map-treemap.adoc)
235-
|
236-
[TreeMap time complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/map-hashmap-vs-treemap.adoc#treemap-time-complexity-vs-hashmap)
357+
<details>
358+
<summary>
359+
Implement a binary search tree for fast lookups.
360+
</summary>
237361

238-
3. **Graphs**: data **nodes** that can have a connection or **edge** to
239-
zero or more adjacent nodes. Unlike trees, nodes can have multiple
240-
parents, loops.
241-
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/graphs/graph.js)
242-
|
243-
[Graph Time Complexity](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/graph.adoc#graph-complexity)
244-
<!-- [Post](https://adrianmejia.com/blog/2018/05/14/data-structures-for-beginners-graphs-time-complexity-tutorial/) -->
362+
---
363+
364+
#### [Implement a binary search tree for fast lookups](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/tree-binary-search-tree.adoc)
365+
366+
- Learn how to add/remove/update values in a tree:
367+
![inserting node in a tree](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/raw/master/book/images/image36.png)
368+
369+
- [How to make a tree balanced?](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/tree-self-balancing-rotations.adoc)
370+
371+
From unbalanced BST to balanced BST
372+
```
373+
1 2
374+
\ / \
375+
2 => 1 3
376+
\
377+
3
378+
```
379+
380+
381+
---
382+
383+
</details>
384+
</blockquote>
385+
386+
### [Algorithms Techniques](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/part4.adoc)
387+
388+
- Never get stuck solving a problem with 7 simple steps.
389+
- Master the most popular sorting algorithms (mergesort, quicksort, insertion sort, ...)
390+
- Learn different approaches to solve problems such as divide and conquer, dynamic programming, greedy algorithms, and backtracking.
391+
392+
<blockquote>
393+
<details>
394+
<summary>
395+
Never get stuck solving a problem with 7 simple steps
396+
</summary>
245397

246-
## Algorithms
398+
---
399+
400+
#### [Never get stuck solving a problem with 7 simple steps](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/algorithmic-toolbox.adoc)
401+
402+
1. Understand the problem
403+
1. Build a simple example (no edge cases yet)
404+
1. Brainstorm solutions (greedy algorithm, Divide and Conquer, Backtracking, brute force)
405+
1. Test your solution on the simple example (mentally)
406+
1. Optimize the solution
407+
1. Write Code, yes, now you can code.
408+
1. Test your written code
409+
410+
Full details [here](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/algorithmic-toolbox.adoc)
247411

248-
- Sorting algorithms
412+
---
413+
414+
</details>
415+
<details>
416+
<summary>
417+
Master the most popular sorting algorithms (mergesort, quicksort, insertion sort, ...)
418+
</summary>
249419

420+
---
421+
422+
#### [Master the most popular sorting algorithms](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/sorting-intro.adoc)
423+
424+
We are going to explore three basic sorting algorithms O(n2) which have low overhead:
250425
- Bubble Sort.
251426
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/bubble-sort.js)
252427
|
@@ -262,6 +437,7 @@ We are covering the following data structures.
262437
|
263438
[Docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/selection-sort.adoc)
264439

440+
and then discuss efficient sorting algorithms O(n log n) such as:
265441
- Merge Sort.
266442
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/merge-sort.js)
267443
|
@@ -272,35 +448,70 @@ We are covering the following data structures.
272448
|
273449
[Docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/quick-sort.adoc)
274450

275-
- Greedy Algorithms
451+
---
276452

277-
- Fractional Knapsack Problem.
278-
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/knapsack-fractional.js)
279-
|
280-
[Docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/greedy-algorithms--knapsack-problem.adoc)
453+
</details>
454+
<details>
455+
<summary>
456+
Learn different approaches to solve problems such as divide and conquer, dynamic programming, greedy algorithms, and backtracking.
457+
</summary>
281458

282-
- Divide and Conquer
459+
---
283460

284-
- Merge Sort.
285-
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/merge-sort.js)
286-
|
287-
[Docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/merge-sort.adoc)
461+
#### [Learn different approaches to solve algorithmic problems](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/algorithms-intro.adoc)
288462

289-
- Fibonacci Numbers.
290-
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/fibonacci-recursive.js)
291-
|
292-
[Docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/divide-and-conquer--fibonacci.adoc)
463+
We are going to discuss the following techniques for solving algorithms problems:
464+
- [Greedy Algorithms](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/greedy-algorithms.adoc): makes greedy choices using heuristics to find the best solution without looking back.
465+
- [Dynamic Programming](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/dynamic-programming.adoc): a technique for speeding up recursive algorithms when there are many _overlapping subproblems_. It uses _memoization_ to avoid duplicating work.
466+
- [Divide and Conquer](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/divide-and-conquer.adoc): _divide_ problems into smaller pieces, _conquer_ each subproblem and then _join_ the results.
467+
- [Backtracking](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/book/chapters/backtracking.adoc): search _all (or some)_ possible paths. However, it stops and _go back_ as soon as notice the current solution is not working.
468+
- _Brute Force_: generate all possible solutions and tries all of them. (Use it as a last resort or as the starting point to optimize it with other techniques).
293469

294-
- Dynamic Programming
470+
---
295471

296-
- Fibonacci with memoization.
297-
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/fibanacci-dynamic-programming.js)
298-
|
299-
[Docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/dynamic-programming--knapsack-problem.adoc)
472+
</details>
473+
</blockquote>
300474

301-
- Backtracking algorithms
475+
## FAQ
302476

303-
- Word permutations.
304-
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/permutations-backtracking.js)
305-
|
306-
[Docs](https://github.com/amejiarosario/dsa.js/blob/master/book/chapters/backtracking.adoc)
477+
<details>
478+
<summary>How would I apply these to my day-to-day work?</summary>
479+
<p>
480+
As a programmer, we have to solve problems every day. If you want to solve problems well, then it's good to
481+
know about a broad range of solutions. A lot of times, it's more efficient to learn existing resources than
482+
stumble upon the answer yourself. The more tools and practice you have, the better. This book helps you
483+
understand the tradeoffs among data structures and reason about algorithms performance.
484+
</p>
485+
</details>
486+
487+
<details>
488+
<summary>Hey OP, why you created this repo/book?</summary>
489+
<p>
490+
There are not many books about Algorithms in JavaScript. This material fills the gap.
491+
Also, it's good practice :)
492+
</p>
493+
</details>
494+
495+
<details>
496+
<summary>Is there anyone I can contact if I have questions about something in particular?
497+
</summary>
498+
<p>
499+
Yes, open an issue or ask questions on the slack channel.
500+
</p>
501+
</details>
502+
503+
## Support
504+
505+
Reach out to me at one of the following places!
506+
507+
- Twitter at <a href="http://twitter.com/amejiarosario" target="_blank">`@amejiarosario`</a>
508+
- Slack at <a href="https://dsajs-slackin.herokuapp.com" target="_blank">`dsajs.slack.com`</a>
509+
510+
511+
## Donations
512+
513+
The best way to support this project is buying the [book](https://books.adrianmejia.com/dsajs-data-structures-algorithms-javascript/), so I can invest more time into this project and keep improving it.
514+
515+
## License
516+
517+
[![License](https://img.shields.io/:license-mit-blue.svg?style=flat-square)](https://github.com/amejiarosario/dsa.js-data-structures-and-algorithms-in-javascript/blob/master/LICENSE)

‎notes.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ New features in this release
3333
git log <last release> HEAD --grep feat
3434
```
3535

36+
# Generate TOC
37+
38+
Install
39+
```
40+
npm install -g doctoc
41+
```
42+
43+
Add to *.md:
44+
```
45+
<!-- START doctoc -->
46+
<!-- END doctoc -->
47+
```
48+
49+
Run:
50+
```
51+
doctoc README.md
52+
```
53+
3654

3755
# Roadmap
3856
- [x] PDF: callouts and emojis are not showing correctly

0 commit comments

Comments
 (0)
Please sign in to comment.