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: book/chapters/algorithms-analysis.adoc
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,7 @@ TIP: Algorithms are instructions on how to perform a task.
47
47
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!
48
48
49
49
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)))
50
51
51
52
.Relationship between algorithm input size and time taken to complete
52
53
[cols=",,,,,",options="header",]
@@ -110,8 +111,9 @@ When we are comparing algorithms, we don't want to have complex expressions. Wha
110
111
TIP: Asymptotic analysis describes the behavior of functions as their inputs approach to infinity.
111
112
112
113
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)))
113
115
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`
Copy file name to clipboardExpand all lines: book/chapters/big-o-examples.adoc
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,7 +245,9 @@ Factorial start very slow and then it quickly becomes uncontrollable. A word siz
245
245
== Summary
246
246
247
247
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)))
248
249
250
+
// tag::table[]
249
251
.Most common algorithmic running times and their examples
250
252
[cols="2,2,5",options="header"]
251
253
|===
@@ -285,3 +287,4 @@ We went through 8 of the most common time complexities and provided examples for
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)))
290
291
292
+
// tag::table[]
291
293
.Time complexity for a Hash Map
292
294
|===
293
295
.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)*
{empty}* = Amortized run time. E.g. rehashing might affect run time.
301
+
// end::table[]
299
302
300
303
indexterm:[Runtime, Linear]
301
304
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)*.
Copy file name to clipboardExpand all lines: book/chapters/preface.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ This publication is designed to be concise, intending to serve software develope
11
11
12
12
This book is for software developers familiar with JavaScript looking to improve their problem-solving skills or preparing for a job interview.
13
13
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.
0 commit comments