Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 780b28a

Browse files
labling tables
1 parent bfde129 commit 780b28a

14 files changed

+41
-44
lines changed

‎book/chapters/algorithms-analysis.adoc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ TIP: Algorithms are instructions on how to perform a task.
4747
Not all algorithms are created equal. There are "good" and "bad" algorithms. The good ones are fast; the bad ones are slow. Slow algorithms cost more money to run. Inefficient algorithms could make some calculations impossible in our lifespan!
4848

4949
To give you a clearer picture of how different algorithms perform as the input size grows, take a look at the following problems and how their relative execution time changes as the input size increases.
50+
(((table)))
5051

5152
.Relationship between algorithm input size and time taken to complete
5253
[cols=",,,,,",options="header",]
@@ -110,8 +111,9 @@ When we are comparing algorithms, we don't want to have complex expressions. Wha
110111
TIP: Asymptotic analysis describes the behavior of functions as their inputs approach to infinity.
111112

112113
In the previous example, we analyzed `getMin` with an array of size 3; what happen size is 10 or 10k or a million?
114+
(((table)))
113115

114-
.Operations performed by an algorithm with a time complexity of 3n+3
116+
.Operations performed by an algorithm with a time complexity of `3n + 3`
115117
[cols=",,",options="header",]
116118
|===========================
117119
|n (size) |Operations |total

‎book/chapters/array.adoc‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ Runtime: O(1).
203203
== Array Complexity
204204

205205
To sum up, the time complexity on an array is:
206+
(((table)))
206207

208+
// tag::table[]
207209
.Time/Space complexity for the array operations
208210
|===
209211
.2+.^s| Data Structure 2+^s| Searching By 3+^s| Inserting at the 3+^s| Deleting from .2+.^s| Space
@@ -215,7 +217,7 @@ To sum up, the time complexity on an array is:
215217
(((Constant)))
216218
(((Runtime, Constant)))
217219

218-
Array Operations
220+
.Array Operations timex complexity
219221
|===
220222
| Operation | Time Complexity | Usage
221223
| push ^| O(1) | Insert element to the right side.
@@ -224,3 +226,4 @@ Array Operations
224226
| shift ^| O(n) | Remove leftmost element.
225227
| splice ^| O(n) | Insert and remove from anywhere.
226228
|===
229+
//end::table

‎book/chapters/big-o-examples.adoc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ Factorial start very slow and then it quickly becomes uncontrollable. A word siz
245245
== Summary
246246

247247
We went through 8 of the most common time complexities and provided examples for each of them. Hopefully, this will give you a toolbox to analyze algorithms.
248+
(((table)))
248249

250+
// tag::table[]
249251
.Most common algorithmic running times and their examples
250252
[cols="2,2,5",options="header"]
251253
|===
@@ -285,3 +287,4 @@ We went through 8 of the most common time complexities and provided examples for
285287
|<<Factorial>>
286288
|<<factorial-example>>
287289
|===
290+
// end::table[]

‎book/chapters/cheatsheet.adoc‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,7 @@ This section summerize what we are going to cover in the rest of this book.
55

66
== Runtimes
77

8-
.Most common algorithmic running times and their examples
9-
[cols="2,2,5",options="header"]
10-
|===
11-
|Big O Notation
12-
|Name
13-
|Example(s)
14-
15-
|O(1)
16-
|<<Constant>>
17-
|#<<constant-example>>, #<<linked-list-inserting-beginning>>
18-
19-
|O(log n)
20-
|<<Logarithmic>>
21-
|<<logarithmic-example>>
22-
23-
|O(n)
24-
|<<Linear>>
25-
|<<linear-example>>
26-
27-
|O(n log n)
28-
|<<Linearithmic>>
29-
|<<linearithmic-example>>
30-
31-
|O(n^2^)
32-
|<<Quadratic>>
33-
|<<quadratic-example>>
34-
35-
|O(n^3^)
36-
|<<Cubic>>
37-
|<<cubic-example>>
38-
39-
|O(2^n^)
40-
|<<Exponential>>
41-
|<<exponential-example>>
42-
43-
|O(n!)
44-
|<<Factorial>>
45-
|<<factorial-example>>
46-
|===
8+
include::big-o-examples.adoc[tag=table]
479

4810
.How long an algorithm takes to run based on their time complexity and input size
4911
[cols=",,,,,,",options="header",]

‎book/chapters/graph.adoc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ include::{codedir}/data-structures/graphs/node.js[tag=removeAdjacent, indent=0]
284284

285285
== Graph Complexity
286286

287+
(((table)))
288+
289+
// tag::table[]
287290
.Time complexity for a Graph data structure
288291
|===
289292
.2+.^s| Data Structure 2+^s| Vertices 2+^s| Edges .2+^.^s| Space Complexity
@@ -292,5 +295,6 @@ include::{codedir}/data-structures/graphs/node.js[tag=removeAdjacent, indent=0]
292295
| Graph (adj. list w/array) ^| O(1) ^| O(\|V\| + \|E\|)) ^|O(1) ^|O(\|V\| + \|E\|) ^|O(\|V\| + \|E\|)
293296
| Graph (adj. list w/HashSet) ^| O(1) ^| O(\|V\|)) ^|O(1) ^|O(\|V\|) ^|O(\|V\| + \|E\|)
294297
|===
298+
// end::table[]
295299

296300
As you can see using a `HashSet` on for the adjacency list make a performance improvement.

‎book/chapters/linear-data-structures-outro.adoc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ In this part of the book, we explored the most used linear data structures such
1818
.Use a Stack when:
1919
* You need to access your data as last-in, first-out (LIFO).
2020
* You need to implement a <<Depth-First Search for Binary Tree, Depth-First Search>>
21+
(((table)))
2122
23+
// tag::table[]
2224
.Time/Space Complexity of Linear Data Structures (Array, LinkedList, Stack & Queues)
2325
|===
2426
.2+.^s| Data Structure 2+^s| Searching By 3+^s| Inserting at the 3+^s| Deleting from .2+.^s| Space
@@ -30,3 +32,4 @@ In this part of the book, we explored the most used linear data structures such
3032
| Queue (w/array) ^|- ^|- ^|- ^|- ^|*O(n)* ^|- ^|- ^|O(1) ^|O(n)
3133
| <<Queue>> (w/list) ^|- ^|- ^|- ^|- ^|O(1) ^|- ^|- ^|O(1) ^|O(n)
3234
|===
35+
// end::table[]

‎book/chapters/linked-list.adoc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ Notice that we are using the `get` method to get the node at the current positio
233233
== Linked List Complexity vs. Array Complexity
234234

235235
So far, we have seen two liner data structures with different use cases. Here’s a summary:
236+
(((table)))
236237

237-
238+
// tag::table[]
238239
.Big O cheat sheet for Linked List and Array
239240
|===
240241
.2+.^s| Data Structure 2+^s| Searching By 3+^s| Inserting at the 3+^s| Deleting from .2+.^s| Space
@@ -243,6 +244,7 @@ So far, we have seen two liner data structures with different use cases. Here’
243244
| Linked List (singly) ^|O(n) ^|O(n) ^|O(1) ^|O(n) ^|O(1) ^|O(1) ^|O(n) ^|*O(n)* ^|O(n)
244245
| Linked List (doubly) ^|O(n) ^|O(n) ^|O(1) ^|O(n) ^|O(1) ^|O(1) ^|O(n) ^|*O(1)* ^|O(n)
245246
|===
247+
// end::table[]
246248
(((Linear)))
247249
(((Runtime, Linear)))
248250

‎book/chapters/map-hashmap-vs-treemap.adoc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
== TreeMap Time complexity vs HashMap
1616

1717
As we discussed so far, there is a trade-off between the implementations.
18+
(((table)))
1819

20+
// tag::table[]
1921
.Time complexity for different Maps implementations
2022
|===
2123
.2+.^s| Data Structure 2+^s| Searching By .2+^.^s| Insert .2+^.^s| Delete .2+^.^s| Space Complexity
@@ -25,6 +27,7 @@ As we discussed so far, there is a trade-off between the implementations.
2527
| Tree Map (Red-Black Tree) ^|O(log n) ^|O(n) ^|O(log n) ^|O(log n) ^|O(log n)
2628
|===
2729
{empty}* = Amortized run time. E.g. rehashing might affect run time to *O(n)*.
30+
// end::table[]
2831

2932
(((Linear)))
3033
(((Runtime, Linear)))

‎book/chapters/map-hashmap.adoc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ https://github.com/amejiarosario/dsa.js/blob/7694c20d13f6c53457ee24fbdfd3c0ac571
287287
== HashMap time complexity
288288

289289
Hash Map it’s very optimal for searching values by key in constant time *O(1)*. However, searching by value is not any better than an array since we have to visit every value *O(n)*.
290+
(((table)))
290291

292+
// tag::table[]
291293
.Time complexity for a Hash Map
292294
|===
293295
.2+.^s| Data Structure 2+^s| Searching By .2+^.^s| Insert .2+^.^s| Delete .2+^.^s| Space Complexity
@@ -296,6 +298,7 @@ Hash Map it’s very optimal for searching values by key in constant time *O(1)*
296298
| Hash Map (optimized) ^|O(1)* ^|O(n) ^|O(1)* ^|O(1)* ^|O(1)*
297299
|===
298300
{empty}* = Amortized run time. E.g. rehashing might affect run time.
301+
// end::table[]
299302

300303
indexterm:[Runtime, Linear]
301304
As you can notice we have amortized times since, in the unfortunate case of a rehash, it will take O(n) while it resizes. After that, it will be *O(1)*.

‎book/chapters/preface.adoc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This publication is designed to be concise, intending to serve software develope
1111

1212
This book is for software developers familiar with JavaScript looking to improve their problem-solving skills or preparing for a job interview.
1313

14-
NOTE: You can apply the concepts in this book to any programming language. However, instead of doing examples on pseudo-code we are going to use JavaScript to implement the code examples.
14+
NOTE: You can apply the concepts in this book to any programming language. However, instead of doing examples in pseudo-code we are going to use JavaScript to implement the code examples.
1515

1616
== What you need for this book
1717

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /