-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2021-03-18_The-Web-Developer-s-Technical-Interview-e347d7db3822.html
More file actions
4439 lines (4436 loc) · 386 KB
/
2021-03-18_The-Web-Developer-s-Technical-Interview-e347d7db3822.html
File metadata and controls
4439 lines (4436 loc) · 386 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>The Web Developer’s Technical Interview</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<article class="h-entry">
<header>
<h1 class="p-name">The Web Developer’s Technical Interview</h1>
</header>
<section data-field="subtitle" class="p-summary">
Questions….Answers… and links to the missing pieces.
</section>
<section data-field="body" class="e-content">
<section name="7c72" class="section section--body section--first section--last">
<div class="section-divider">
<hr class="section-divider">
</div>
<div class="section-content">
<div class="section-inner sectionLayout--insetColumn">
<h3 name="0273" id="0273" class="graf graf--h3 graf--leading graf--title">The Web Developer’s Technical
Interview</h3>
<h4 name="9332" id="9332" class="graf graf--h4 graf-after--h3 graf--subtitle">Questions….Answers… and
links to the missing pieces.</h4>
<blockquote name="d524" id="d524" class="graf graf--blockquote graf-after--h4"><strong
class="markup--strong markup--blockquote-strong"><em
class="markup--em markup--blockquote-em">Resources first… the actual article is below!</em></strong>
</blockquote>
<figure name="3ee3" id="3ee3" class="graf graf--figure graf-after--blockquote"><img class="graf-image"
data-image-id="1*-fWJcnbTfusuDCBTI58avg.png" data-width="530" data-height="332"
data-is-featured="true" src="https://cdn-images-1.medium.com/max/800/1*-fWJcnbTfusuDCBTI58avg.png">
<figcaption class="imageCaption"><a href="https://trusting-dijkstra-4d3b17.netlify.app/"
data-href="https://trusting-dijkstra-4d3b17.netlify.app/"
class="markup--anchor markup--figure-anchor" rel="nofollow noopener"
target="_blank">https://trusting-dijkstra-4d3b17.netlify.app/</a></figcaption>
</figure>
<h4 name="4470" id="4470" class="graf graf--h4 graf-after--figure">First off.. Here’s a link to a website
I created for practicing with data structures in javascript:</h4>
<div name="a136" id="a136" class="graf graf--mixtapeEmbed graf-after--h4"><a
href="https://trusting-dijkstra-4d3b17.netlify.app/"
data-href="https://trusting-dijkstra-4d3b17.netlify.app/"
class="markup--anchor markup--mixtapeEmbed-anchor"
title="https://trusting-dijkstra-4d3b17.netlify.app/"><strong
class="markup--strong markup--mixtapeEmbed-strong">Playground</strong><br><em
class="markup--em markup--mixtapeEmbed-em">Edit
description</em>trusting-dijkstra-4d3b17.netlify.app</a><a
href="https://trusting-dijkstra-4d3b17.netlify.app/"
class="js-mixtapeImage mixtapeImage mixtapeImage--empty u-ignoreBlock"
data-media-id="b1d4b7807ff2f2ac306eb3f8402409af"></a></div>
<h3 name="f69c" id="f69c" class="graf graf--h3 graf-after--mixtapeEmbed">Here’s a live code editor where
you can mess with any of the examples…</h3>
</div>
<div class="section-inner sectionLayout--fullWidth">
<figure name="a042" id="a042" class="graf graf--figure graf--iframe graf--layoutFillWidth graf-after--h3">
<iframe src="https://repl.it/@bgoonz/DS-ALGO-OFFICIAL-2?lite=true" width="null" height="null"
frameborder="0" scrolling="no"></iframe></figure>
</div>
<div class="section-inner sectionLayout--insetColumn">
<h4 name="122b" id="122b" class="graf graf--h4 graf-after--figure">And here’s the part where I go through
leetcode problems:</h4>
<div name="8aaf" id="8aaf" class="graf graf--mixtapeEmbed graf-after--h4"><a
href="https://trusting-dijkstra-4d3b17.netlify.app/container/ds-n-algos/sandbox/leetmd/completeleetcode"
data-href="https://trusting-dijkstra-4d3b17.netlify.app/container/ds-n-algos/sandbox/leetmd/completeleetcode"
class="markup--anchor markup--mixtapeEmbed-anchor"
title="https://trusting-dijkstra-4d3b17.netlify.app/container/ds-n-algos/sandbox/leetmd/completeleetcode"><strong
class="markup--strong markup--mixtapeEmbed-strong">LEETCODE</strong><br><em
class="markup--em markup--mixtapeEmbed-em">You are given two non-empty linked lists representing two
non-negative integers. The digits are stored in reverse
order…</em>trusting-dijkstra-4d3b17.netlify.app</a><a
href="https://trusting-dijkstra-4d3b17.netlify.app/container/ds-n-algos/sandbox/leetmd/completeleetcode"
class="js-mixtapeImage mixtapeImage u-ignoreBlock" data-media-id="27a3f0259791581690ab8eeb23eeeba6"
data-thumbnail-img-id="0*qBTf9nY7p6FLnRbs"
style="background-image: url(https://cdn-images-1.medium.com/fit/c/160/160/0*qBTf9nY7p6FLnRbs);"></a>
</div>
<h4 name="f006" id="f006" class="graf graf--h4 graf-after--mixtapeEmbed">Additionally, here’s another
Medium Article I wrote on data structures:</h4>
<div name="5794" id="5794" class="graf graf--mixtapeEmbed graf-after--h4"><a
href="https://medium.com/codex/fundamental-data-structures-in-javascript-8f9f709c15b4"
data-href="https://medium.com/codex/fundamental-data-structures-in-javascript-8f9f709c15b4"
class="markup--anchor markup--mixtapeEmbed-anchor"
title="https://medium.com/codex/fundamental-data-structures-in-javascript-8f9f709c15b4"><strong
class="markup--strong markup--mixtapeEmbed-strong">Fundamental Data Structures In
JavaScript</strong><br><em class="markup--em markup--mixtapeEmbed-em">Data structures in
JavaScript</em>medium.com</a><a
href="https://medium.com/codex/fundamental-data-structures-in-javascript-8f9f709c15b4"
class="js-mixtapeImage mixtapeImage u-ignoreBlock" data-media-id="ab7d9961639bd94a7e08239764e35b07"
data-thumbnail-img-id="0*avbxLAFocSV6vsl5.gif"
style="background-image: url(https://cdn-images-1.medium.com/fit/c/160/160/0*avbxLAFocSV6vsl5.gif);"></a>
</div>
<h4 name="d16e" id="d16e" class="graf graf--h4 graf-after--mixtapeEmbed">All the code provided in this
article will be embeded at the bottom of this article as a gist so that you can see the proper syntax
highlighting… and copy it all at once if you like!</h4>
<h3 name="323e" id="323e" class="graf graf--h3 graf-after--h4">Asymptotic Notation</h3>
<figure name="5265" id="5265" class="graf graf--figure graf-after--h3"><img class="graf-image"
data-image-id="1*rHF5Jb6Cv_vxiZKg06Abtg.png" data-width="843" data-height="741"
src="https://cdn-images-1.medium.com/max/800/1*rHF5Jb6Cv_vxiZKg06Abtg.png"></figure>
<h3 name="21ae" id="21ae" class="graf graf--h3 graf-after--figure">Definition:</h3>
<p name="eac8" id="eac8" class="graf graf--p graf-after--h3">Asymptotic Notation is the hardware
independent notation used to tell the time and space complexity of an algorithm. Meaning it’s a
standardized way of measuring how much memory an algorithm uses or how long it runs for given an input.
</p>
<h4 name="a769" id="a769" class="graf graf--h4 graf-after--p">Complexities</h4>
<p name="e239" id="e239" class="graf graf--p graf-after--h4">The following are the Asymptotic rates of
growth from best to worst:</p>
<ul class="postList">
<li name="3de8" id="3de8" class="graf graf--li graf-after--p">constant growth — <code
class="markup--code markup--li-code">O(1)</code> Runtime is constant and does not grow with <code
class="markup--code markup--li-code">n</code></li>
<li name="3386" id="3386" class="graf graf--li graf-after--li">logarithmic growth — <code
class="markup--code markup--li-code">O(log n)</code> Runtime grows logarithmically in proportion to
<code class="markup--code markup--li-code">n</code></li>
<li name="ee6b" id="ee6b" class="graf graf--li graf-after--li">linear growth — <code
class="markup--code markup--li-code">O(n)</code> Runtime grows directly in proportion to <code
class="markup--code markup--li-code">n</code></li>
<li name="7148" id="7148" class="graf graf--li graf-after--li">superlinear growth — <code
class="markup--code markup--li-code">O(n log n)</code> Runtime grows in proportion <em
class="markup--em markup--li-em">and</em> logarithmically to <code
class="markup--code markup--li-code">n</code></li>
<li name="3700" id="3700" class="graf graf--li graf-after--li">polynomial growth — <code
class="markup--code markup--li-code">O(n^c)</code> Runtime grows quicker than previous all based on
<code class="markup--code markup--li-code">n</code></li>
<li name="08ce" id="08ce" class="graf graf--li graf-after--li">exponential growth — <code
class="markup--code markup--li-code">O(c^n)</code> Runtime grows even faster than polynomial growth
based on <code class="markup--code markup--li-code">n</code></li>
<li name="e970" id="e970" class="graf graf--li graf-after--li">factorial growth — <code
class="markup--code markup--li-code">O(n!)</code> Runtime grows the fastest and becomes quickly
unusable for even<br>small values of <code class="markup--code markup--li-code">n</code></li>
</ul>
<p name="e266" id="e266" class="graf graf--p graf-after--li"><a
href="https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/"
data-href="https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/"
class="markup--anchor markup--p-anchor" rel="noopener" target="_blank">(source: Soumyadeep Debnath,
<em class="markup--em markup--p-em">Analysis of Algorithms | Big-O analysis</em>)</a></p>
<p name="fe52" id="fe52" class="graf graf--p graf-after--p">Visualized below; the x-axis representing
input size and the y-axis representing complexity:</p>
<figure name="3485" id="3485" class="graf graf--figure graf-after--p"><img class="graf-image"
data-image-id="0*EhERM_cwojSYpuh9.png" data-width="400" data-height="400"
src="https://cdn-images-1.medium.com/max/800/0*EhERM_cwojSYpuh9.png"></figure>
<p name="5eab" id="5eab" class="graf graf--p graf-after--figure"><a
href="https://en.wikipedia.org/wiki/Computational_complexity_of_mathematical_operations"
data-href="https://en.wikipedia.org/wiki/Computational_complexity_of_mathematical_operations"
class="markup--anchor markup--p-anchor" rel="noopener" target="_blank">(source: Wikipedia, <em
class="markup--em markup--p-em">Computational Complexity of Mathematical Operations</em>)</a></p>
<h4 name="0fd2" id="0fd2" class="graf graf--h4 graf-after--p">Big-O notation</h4>
<p name="c4ea" id="c4ea" class="graf graf--p graf-after--h4">Big-O refers to the upper bound of time or
space complexity of an algorithm, meaning it worst case runtime scenario. An easy way to think of it is
that runtime could be better than Big-O but it will never be worse.</p>
<h4 name="956a" id="956a" class="graf graf--h4 graf-after--p">Big-Ω (Big-Omega) notation</h4>
<p name="fb79" id="fb79" class="graf graf--p graf-after--h4">Big-Omega refers to the lower bound of time
or space complexity of an algorithm, meaning it is the best runtime scenario. Or runtime could worse
than Big-Omega, but it will never be better.</p>
<h4 name="6016" id="6016" class="graf graf--h4 graf-after--p">Big-θ (Big-Theta) notation</h4>
<p name="e9ae" id="e9ae" class="graf graf--p graf-after--h4">Big-Theta refers to the tight bound of time
or space complexity of an algorithm. Another way to think of it is the intersection of Big-O and
Big-Omega, or more simply runtime is guaranteed to be a given complexity, such as <code
class="markup--code markup--p-code">n log n</code>.</p>
<h4 name="3669" id="3669" class="graf graf--h4 graf-after--p">What you need to know</h4>
<ul class="postList">
<li name="ee4b" id="ee4b" class="graf graf--li graf-after--h4">Big-O and Big-Theta are the most common
and helpful notations</li>
<li name="f77f" id="f77f" class="graf graf--li graf-after--li">Big-O does <em
class="markup--em markup--li-em">not</em> mean Worst Case Scenario, Big-Theta does <em
class="markup--em markup--li-em">not</em> mean average case, and Big-Omega does <em
class="markup--em markup--li-em">not</em> mean Best Case Scenario. They only connote the algorithm’s
performance for a particular scenario, and all three can be used for any scenario.</li>
<li name="1dc8" id="1dc8" class="graf graf--li graf-after--li">Worst Case means given an unideal input,
Average Case means given a typical input, Best case means a ideal input. Ex. Worst case means given an
input the algorithm performs particularly bad, or best case an already sorted array for a sorting
algorithm.</li>
<li name="b7d2" id="b7d2" class="graf graf--li graf-after--li">Best Case and Big Omega are generally not
helpful since Best Cases are rare in the real world and lower bound might be very different than an
upper bound.</li>
<li name="d09f" id="d09f" class="graf graf--li graf-after--li">Big-O isn’t everything. On paper merge
sort is faster than quick sort, but in practice quick sort is superior.</li>
</ul>
<h3 name="5d2a" id="5d2a" class="graf graf--h3 graf-after--li">Data Structures</h3>
<h3 name="ad70" id="ad70" class="graf graf--h3 graf-after--h3">Array</h3>
<h4 name="e80a" id="e80a" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="9e0b" id="9e0b" class="graf graf--li graf-after--h4">Stores data elements based on an
sequential, most commonly 0 based, index.</li>
<li name="79bc" id="79bc" class="graf graf--li graf-after--li">Based on <a
href="http://en.wikipedia.org/wiki/Tuple" data-href="http://en.wikipedia.org/wiki/Tuple"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">tuples</a> from set theory.
</li>
<li name="e483" id="e483" class="graf graf--li graf-after--li">They are one of the oldest, most commonly
used data structures.</li>
</ul>
<h4 name="c3d0" id="c3d0" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="b186" id="b186" class="graf graf--li graf-after--h4">Optimal for indexing; bad at searching,
inserting, and deleting (except at the end).</li>
<li name="6e74" id="6e74" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Linear arrays</strong>, or one dimensional arrays, are the
most basic.</li>
<li name="9e61" id="9e61" class="graf graf--li graf-after--li">Are static in size, meaning that they are
declared with a fixed size.</li>
<li name="e942" id="e942" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Dynamic arrays</strong> are like one dimensional arrays,
but have reserved space for additional elements.</li>
<li name="5341" id="5341" class="graf graf--li graf-after--li">If a dynamic array is full, it copies its
contents to a larger array.</li>
<li name="b6ea" id="b6ea" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Multi dimensional arrays</strong> nested arrays that allow
for multiple dimensions such as an array of arrays providing a 2 dimensional spacial representation
via x, y coordinates.</li>
</ul>
<h4 name="dbf9" id="dbf9" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="a6ec" id="a6ec" class="graf graf--li graf-after--h4">Indexing: Linear array: <code
class="markup--code markup--li-code">O(1)</code>, Dynamic array: <code
class="markup--code markup--li-code">O(1)</code></li>
<li name="e131" id="e131" class="graf graf--li graf-after--li">Search: Linear array: <code
class="markup--code markup--li-code">O(n)</code>, Dynamic array: <code
class="markup--code markup--li-code">O(n)</code></li>
<li name="9791" id="9791" class="graf graf--li graf-after--li">Optimized Search: Linear array: <code
class="markup--code markup--li-code">O(log n)</code>, Dynamic array: <code
class="markup--code markup--li-code">O(log n)</code></li>
<li name="b8a3" id="b8a3" class="graf graf--li graf-after--li">Insertion: Linear array: n/a, Dynamic
array: <code class="markup--code markup--li-code">O(n)</code></li>
</ul>
<h3 name="14a0" id="14a0" class="graf graf--h3 graf-after--li">Linked List</h3>
<h4 name="27cf" id="27cf" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="f6e2" id="f6e2" class="graf graf--li graf-after--h4">Stores data with <strong
class="markup--strong markup--li-strong">nodes</strong> that point to other nodes.</li>
<li name="f98c" id="f98c" class="graf graf--li graf-after--li">Nodes, at its most basic it has one datum
and one reference (another node).</li>
<li name="e75e" id="e75e" class="graf graf--li graf-after--li">A linked list <em
class="markup--em markup--li-em">chains</em> nodes together by pointing one node’s reference towards
another node.</li>
</ul>
<h4 name="b508" id="b508" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="26a7" id="26a7" class="graf graf--li graf-after--h4">Designed to optimize insertion and
deletion, slow at indexing and searching.</li>
<li name="62ee" id="62ee" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Doubly linked list</strong> has nodes that also reference
the previous node.</li>
<li name="63e4" id="63e4" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Circularly linked list</strong> is simple linked list whose
<strong class="markup--strong markup--li-strong">tail</strong>, the last node, references the <strong
class="markup--strong markup--li-strong">head</strong>, the first node.</li>
<li name="2f5d" id="2f5d" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Stack</strong>, commonly implemented with linked lists but
can be made from arrays too.</li>
<li name="cfd5" id="cfd5" class="graf graf--li graf-after--li">Stacks are <strong
class="markup--strong markup--li-strong">last in, first out</strong> (LIFO) data structures.</li>
<li name="d084" id="d084" class="graf graf--li graf-after--li">Made with a linked list by having the
head be the only place for insertion and removal.</li>
<li name="0f69" id="0f69" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Queues</strong>, too can be implemented with a linked list
or an array.</li>
<li name="7ff4" id="7ff4" class="graf graf--li graf-after--li">Queues are a <strong
class="markup--strong markup--li-strong">first in, first out</strong> (FIFO) data structure.</li>
<li name="ec12" id="ec12" class="graf graf--li graf-after--li">Made with a doubly linked list that only
removes from head and adds to tail.</li>
</ul>
<h4 name="c617" id="c617" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="14e9" id="14e9" class="graf graf--li graf-after--h4">Indexing: Linked Lists: <code
class="markup--code markup--li-code">O(n)</code></li>
<li name="ed61" id="ed61" class="graf graf--li graf-after--li">Search: Linked Lists: <code
class="markup--code markup--li-code">O(n)</code></li>
<li name="f302" id="f302" class="graf graf--li graf-after--li">Optimized Search: Linked Lists: <code
class="markup--code markup--li-code">O(n)</code></li>
<li name="34b8" id="34b8" class="graf graf--li graf-after--li">Append: Linked Lists: <code
class="markup--code markup--li-code">O(1)</code></li>
<li name="b1df" id="b1df" class="graf graf--li graf-after--li">Prepend: Linked Lists: <code
class="markup--code markup--li-code">O(1)</code></li>
<li name="d025" id="d025" class="graf graf--li graf-after--li">Insertion: Linked Lists: <code
class="markup--code markup--li-code">O(n)</code></li>
</ul>
<h3 name="96d1" id="96d1" class="graf graf--h3 graf-after--li">Hash Table or Hash Map</h3>
<h4 name="2f8a" id="2f8a" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="3ca5" id="3ca5" class="graf graf--li graf-after--h4">Stores data with key value pairs.</li>
<li name="267d" id="267d" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Hash functions</strong> accept a key and return an output
unique only to that specific key.</li>
<li name="6686" id="6686" class="graf graf--li graf-after--li">This is known as <strong
class="markup--strong markup--li-strong">hashing</strong>, which is the concept that an input and an
output have a one-to-one correspondence to map information.</li>
<li name="f023" id="f023" class="graf graf--li graf-after--li">Hash functions return a unique address in
memory for that data.</li>
</ul>
<h4 name="41da" id="41da" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="3ad0" id="3ad0" class="graf graf--li graf-after--h4">Designed to optimize searching,
insertion, and deletion.</li>
<li name="2fb8" id="2fb8" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Hash collisions</strong> are when a hash function returns
the same output for two distinct inputs.</li>
<li name="e301" id="e301" class="graf graf--li graf-after--li">All hash functions have this problem.
</li>
<li name="e80e" id="e80e" class="graf graf--li graf-after--li">This is often accommodated for by having
the hash tables be very large.</li>
<li name="76d5" id="76d5" class="graf graf--li graf-after--li">Hashes are important for associative
arrays and database indexing.</li>
</ul>
<h4 name="29a7" id="29a7" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="69a6" id="69a6" class="graf graf--li graf-after--h4">Indexing: Hash Tables: <code
class="markup--code markup--li-code">O(1)</code></li>
<li name="ce60" id="ce60" class="graf graf--li graf-after--li">Search: Hash Tables: <code
class="markup--code markup--li-code">O(1)</code></li>
<li name="3b38" id="3b38" class="graf graf--li graf-after--li">Insertion: Hash Tables: <code
class="markup--code markup--li-code">O(1)</code></li>
</ul>
<h3 name="bc20" id="bc20" class="graf graf--h3 graf-after--li">Binary Tree</h3>
<h4 name="2158" id="2158" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="a9dd" id="a9dd" class="graf graf--li graf-after--h4">Is a tree like data structure where every
node has at most two children.</li>
<li name="f794" id="f794" class="graf graf--li graf-after--li">There is one left and right child node.
</li>
</ul>
<h4 name="e7d3" id="e7d3" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="a59b" id="a59b" class="graf graf--li graf-after--h4">Designed to optimize searching and
sorting.</li>
<li name="8701" id="8701" class="graf graf--li graf-after--li">A <strong
class="markup--strong markup--li-strong">degenerate tree</strong> is an unbalanced tree, which if
entirely one-sided, is essentially a linked list.</li>
<li name="a961" id="a961" class="graf graf--li graf-after--li">They are comparably simple to implement
than other data structures.</li>
<li name="8dae" id="8dae" class="graf graf--li graf-after--li">Used to make <strong
class="markup--strong markup--li-strong">binary search trees</strong>.</li>
<li name="215a" id="215a" class="graf graf--li graf-after--li">A binary tree that uses comparable keys
to assign which direction a child is.</li>
<li name="2aa7" id="2aa7" class="graf graf--li graf-after--li">Left child has a key smaller than its
parent node.</li>
<li name="144a" id="144a" class="graf graf--li graf-after--li">Right child has a key greater than its
parent node.</li>
<li name="3683" id="3683" class="graf graf--li graf-after--li">There can be no duplicate node.</li>
<li name="41ec" id="41ec" class="graf graf--li graf-after--li">Because of the above it is more likely to
be used as a data structure than a binary tree.</li>
</ul>
<h4 name="8aa9" id="8aa9" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="95eb" id="95eb" class="graf graf--li graf-after--h4">Indexing: Binary Search Tree: <code
class="markup--code markup--li-code">O(log n)</code></li>
<li name="8bf7" id="8bf7" class="graf graf--li graf-after--li">Search: Binary Search Tree: <code
class="markup--code markup--li-code">O(log n)</code></li>
<li name="883c" id="883c" class="graf graf--li graf-after--li">Insertion: Binary Search Tree: <code
class="markup--code markup--li-code">O(log n)</code></li>
</ul>
<h3 name="fa2d" id="fa2d" class="graf graf--h3 graf-after--li">Algorithms</h3>
<h3 name="c865" id="c865" class="graf graf--h3 graf-after--h3">Algorithm Basics</h3>
<h3 name="b9e9" id="b9e9" class="graf graf--h3 graf-after--h3">Recursive Algorithms</h3>
<h4 name="aced" id="aced" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="1e2e" id="1e2e" class="graf graf--li graf-after--h4">An algorithm that calls itself in its
definition.</li>
<li name="f6bb" id="f6bb" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Recursive case</strong> a conditional statement that is
used to trigger the recursion.</li>
<li name="4db2" id="4db2" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Base case</strong> a conditional statement that is used to
break the recursion.</li>
</ul>
<h4 name="ac4b" id="ac4b" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="80b6" id="80b6" class="graf graf--li graf-after--h4"><strong
class="markup--strong markup--li-strong">Stack level too deep</strong> and <strong
class="markup--strong markup--li-strong">stack overflow</strong>.</li>
<li name="a19b" id="a19b" class="graf graf--li graf-after--li">If you’ve seen either of these from a
recursive algorithm, you messed up.</li>
<li name="c664" id="c664" class="graf graf--li graf-after--li">It means that your base case was never
triggered because it was faulty or the problem was so massive you ran out of alloted memory.</li>
<li name="6326" id="6326" class="graf graf--li graf-after--li">Knowing whether or not you will reach a
base case is integral to correctly using recursion.</li>
<li name="3bb3" id="3bb3" class="graf graf--li graf-after--li">Often used in Depth First Search</li>
</ul>
<h3 name="cbc6" id="cbc6" class="graf graf--h3 graf-after--li">Iterative Algorithms</h3>
<h4 name="1982" id="1982" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="6f3f" id="6f3f" class="graf graf--li graf-after--h4">An algorithm that is called repeatedly
but for a finite number of times, each time being a single iteration.</li>
<li name="da8a" id="da8a" class="graf graf--li graf-after--li">Often used to move incrementally through
a data set.</li>
</ul>
<h4 name="7482" id="7482" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="42fe" id="42fe" class="graf graf--li graf-after--h4">Generally you will see iteration as
loops, for, while, and until statements.</li>
<li name="bfa7" id="bfa7" class="graf graf--li graf-after--li">Think of iteration as moving one at a
time through a set.</li>
<li name="d077" id="d077" class="graf graf--li graf-after--li">Often used to move through an array.</li>
</ul>
<h4 name="80fe" id="80fe" class="graf graf--h4 graf-after--li">Recursion Vs. Iteration</h4>
<ul class="postList">
<li name="972e" id="972e" class="graf graf--li graf-after--h4">The differences between recursion and
iteration can be confusing to distinguish since both can be used to implement the other. But know
that,</li>
<li name="0620" id="0620" class="graf graf--li graf-after--li">Recursion is, usually, more expressive
and easier to implement.</li>
<li name="2b44" id="2b44" class="graf graf--li graf-after--li">Iteration uses less memory.</li>
<li name="65b8" id="65b8" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Functional languages</strong> tend to use recursion. (i.e.
Haskell)</li>
<li name="6cf8" id="6cf8" class="graf graf--li graf-after--li"><strong
class="markup--strong markup--li-strong">Imperative languages</strong> tend to use iteration. (i.e.
Ruby)</li>
<li name="ba9f" id="ba9f" class="graf graf--li graf-after--li">Check out this <a
href="http://stackoverflow.com/questions/19794739/what-is-the-difference-between-iteration-and-recursion"
data-href="http://stackoverflow.com/questions/19794739/what-is-the-difference-between-iteration-and-recursion"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">Stack Overflow post</a> for
more info.</li>
</ul>
<h4 name="dd7c" id="dd7c" class="graf graf--h4 graf-after--li">Pseudo Code of Moving Through an Array</h4>
<pre name="8ceb" id="8ceb"
class="graf graf--pre graf-after--h4"><code class="markup--code markup--pre-code">Recursion | Iteration<br>----------------------------------|----------------------------------<br>recursive method (array, n) | iterative method (array)<br> if array[n] is not nil | for n from 0 to size of array<br> print array[n] | print(array[n])<br> recursive method(array, n+1) |<br> else |<br> exit loop |</code></pre>
<h3 name="8f62" id="8f62" class="graf graf--h3 graf-after--pre">Greedy Algorithms</h3>
<h4 name="b056" id="b056" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="7bd2" id="7bd2" class="graf graf--li graf-after--h4">An algorithm that, while executing,
selects only the information that meets a certain criteria.</li>
<li name="d21c" id="d21c" class="graf graf--li graf-after--li">The general five components, taken from
<a href="http://en.wikipedia.org/wiki/Greedy_algorithm#Specifics"
data-href="http://en.wikipedia.org/wiki/Greedy_algorithm#Specifics"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">Wikipedia</a>:</li>
<li name="5ba5" id="5ba5" class="graf graf--li graf-after--li">A candidate set, from which a solution is
created.</li>
<li name="6098" id="6098" class="graf graf--li graf-after--li">A selection function, which chooses the
best candidate to be added to the solution.</li>
<li name="ec09" id="ec09" class="graf graf--li graf-after--li">A feasibility function, that is used to
determine if a candidate can be used to contribute to a solution.</li>
<li name="8a35" id="8a35" class="graf graf--li graf-after--li">An objective function, which assigns a
value to a solution, or a partial solution.</li>
<li name="b10b" id="b10b" class="graf graf--li graf-after--li">A solution function, which will indicate
when we have discovered a complete solution.</li>
</ul>
<h4 name="4918" id="4918" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="97fc" id="97fc" class="graf graf--li graf-after--h4">Used to find the expedient, though
non-optimal, solution for a given problem.</li>
<li name="e9ec" id="e9ec" class="graf graf--li graf-after--li">Generally used on sets of data where only
a small proportion of the information evaluated meets the desired result.</li>
<li name="6120" id="6120" class="graf graf--li graf-after--li">Often a greedy algorithm can help reduce
the Big O of an algorithm.</li>
</ul>
<h4 name="1010" id="1010" class="graf graf--h4 graf-after--li">Pseudo Code of a Greedy Algorithm to Find
Largest Difference of any Two Numbers in an Array.</h4>
<pre name="1e26" id="1e26"
class="graf graf--pre graf-after--h4"><code class="markup--code markup--pre-code">greedy algorithm (array)<br> let largest difference = 0<br> let new difference = find next difference (array[n], array[n+1])<br> largest difference = new difference if new difference is > largest difference<br> repeat above two steps until all differences have been found<br> return largest difference</code></pre>
<p name="9580" id="9580" class="graf graf--p graf-after--pre">This algorithm never needed to compare all
the differences to one another, saving it an entire iteration.</p>
<h3 name="e64a" id="e64a" class="graf graf--h3 graf-after--p">Search Algorithms</h3>
<h3 name="e29a" id="e29a" class="graf graf--h3 graf-after--h3">Breadth First Search</h3>
<h4 name="d01a" id="d01a" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="dd94" id="dd94" class="graf graf--li graf-after--h4">An algorithm that searches a tree (or
graph) by searching levels of the tree first, starting at the root.</li>
<li name="9f26" id="9f26" class="graf graf--li graf-after--li">It finds every node on the same level,
most often moving left to right.</li>
<li name="6a74" id="6a74" class="graf graf--li graf-after--li">While doing this it tracks the children
nodes of the nodes on the current level.</li>
<li name="4d35" id="4d35" class="graf graf--li graf-after--li">When finished examining a level it moves
to the left most node on the next level.</li>
<li name="7f72" id="7f72" class="graf graf--li graf-after--li">The bottom-right most node is evaluated
last (the node that is deepest and is farthest right of it’s level).</li>
</ul>
<h4 name="f4e5" id="f4e5" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="f109" id="f109" class="graf graf--li graf-after--h4">Optimal for searching a tree that is
wider than it is deep.</li>
<li name="8cd0" id="8cd0" class="graf graf--li graf-after--li">Uses a queue to store information about
the tree while it traverses a tree.</li>
<li name="3971" id="3971" class="graf graf--li graf-after--li">Because it uses a queue it is more memory
intensive than <strong class="markup--strong markup--li-strong">depth first search</strong>.</li>
<li name="9799" id="9799" class="graf graf--li graf-after--li">The queue uses more memory because it
needs to stores pointers</li>
</ul>
<h4 name="77be" id="77be" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="78ea" id="78ea" class="graf graf--li graf-after--h4">Search: Breadth First Search: O(V + E)
</li>
<li name="5161" id="5161" class="graf graf--li graf-after--li">E is number of edges</li>
<li name="fe1a" id="fe1a" class="graf graf--li graf-after--li">V is number of vertices</li>
</ul>
<h3 name="ed3a" id="ed3a" class="graf graf--h3 graf-after--li">Depth First Search</h3>
<h4 name="a92c" id="a92c" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="0675" id="0675" class="graf graf--li graf-after--h4">An algorithm that searches a tree (or
graph) by searching depth of the tree first, starting at the root.</li>
<li name="5851" id="5851" class="graf graf--li graf-after--li">It traverses left down a tree until it
cannot go further.</li>
<li name="c642" id="c642" class="graf graf--li graf-after--li">Once it reaches the end of a branch it
traverses back up trying the right child of nodes on that branch, and if possible left from the right
children.</li>
<li name="9caf" id="9caf" class="graf graf--li graf-after--li">When finished examining a branch it moves
to the node right of the root then tries to go left on all it’s children until it reaches the bottom.
</li>
<li name="55f8" id="55f8" class="graf graf--li graf-after--li">The right most node is evaluated last
(the node that is right of all it’s ancestors).</li>
</ul>
<h4 name="ba3e" id="ba3e" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="8620" id="8620" class="graf graf--li graf-after--h4">Optimal for searching a tree that is
deeper than it is wide.</li>
<li name="a823" id="a823" class="graf graf--li graf-after--li">Uses a stack to push nodes onto.</li>
<li name="8348" id="8348" class="graf graf--li graf-after--li">Because a stack is LIFO it does not need
to keep track of the nodes pointers and is therefore less memory intensive than breadth first search.
</li>
<li name="daf9" id="daf9" class="graf graf--li graf-after--li">Once it cannot go further left it begins
evaluating the stack.</li>
</ul>
<h4 name="fff2" id="fff2" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="eb59" id="eb59" class="graf graf--li graf-after--h4">Search: Depth First Search: O(|E| + |V|)
</li>
<li name="a1f4" id="a1f4" class="graf graf--li graf-after--li">E is number of edges</li>
<li name="3aec" id="3aec" class="graf graf--li graf-after--li">V is number of vertices</li>
</ul>
<h4 name="0e2f" id="0e2f" class="graf graf--h4 graf-after--li">Breadth First Search Vs. Depth First Search
</h4>
<ul class="postList">
<li name="6955" id="6955" class="graf graf--li graf-after--h4">The simple answer to this question is
that it depends on the size and shape of the tree.</li>
<li name="3cb1" id="3cb1" class="graf graf--li graf-after--li">For wide, shallow trees use Breadth First
Search</li>
<li name="90dc" id="90dc" class="graf graf--li graf-after--li">For deep, narrow trees use Depth First
Search</li>
</ul>
<h4 name="6f5c" id="6f5c" class="graf graf--h4 graf-after--li">Nuances</h4>
<ul class="postList">
<li name="8df6" id="8df6" class="graf graf--li graf-after--h4">Because BFS uses queues to store
information about the nodes and its children, it could use more memory than is available on your
computer. (But you probably won’t have to worry about this.)</li>
<li name="429a" id="429a" class="graf graf--li graf-after--li">If using a DFS on a tree that is very
deep you might go unnecessarily deep in the search. See <a href="http://xkcd.com/761/"
data-href="http://xkcd.com/761/" class="markup--anchor markup--li-anchor" rel="noopener"
target="_blank">xkcd</a> for more information.</li>
<li name="8a83" id="8a83" class="graf graf--li graf-after--li">Breadth First Search tends to be a
looping algorithm.</li>
<li name="738e" id="738e" class="graf graf--li graf-after--li">Depth First Search tends to be a
recursive algorithm.</li>
</ul>
<h3 name="26b4" id="26b4" class="graf graf--h3 graf-after--li">Sorting Algorithms</h3>
<h3 name="c98f" id="c98f" class="graf graf--h3 graf-after--h3">Selection Sort</h3>
<h4 name="4d05" id="4d05" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="bd23" id="bd23" class="graf graf--li graf-after--h4">A comparison based sorting algorithm.
</li>
<li name="d6e8" id="d6e8" class="graf graf--li graf-after--li">Starts with the cursor on the left,
iterating left to right</li>
<li name="cb0c" id="cb0c" class="graf graf--li graf-after--li">Compares the left side to the right,
looking for the smallest known item</li>
<li name="5530" id="5530" class="graf graf--li graf-after--li">If the left is smaller than the item to
the right it continues iterating</li>
<li name="73ed" id="73ed" class="graf graf--li graf-after--li">If the left is bigger than the item to
the right, the item on the right becomes the known smallest number</li>
<li name="7fec" id="7fec" class="graf graf--li graf-after--li">Once it has checked all items, it moves
the known smallest to the cursor and advances the cursor to the right and starts over</li>
<li name="8942" id="8942" class="graf graf--li graf-after--li">As the algorithm processes the data set,
it builds a fully sorted left side of the data until the entire data set is sorted</li>
<li name="6cd7" id="6cd7" class="graf graf--li graf-after--li">Changes the array in place.</li>
</ul>
<h4 name="fc8f" id="fc8f" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="7c12" id="7c12" class="graf graf--li graf-after--h4">Inefficient for large data sets.</li>
<li name="a207" id="a207" class="graf graf--li graf-after--li">Very simple to implement.</li>
</ul>
<h4 name="be27" id="be27" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="9948" id="9948" class="graf graf--li graf-after--h4">Best Case Sort: Merge Sort: <code
class="markup--code markup--li-code">O(n^2)</code></li>
<li name="95aa" id="95aa" class="graf graf--li graf-after--li">Average Case Sort: Merge Sort: <code
class="markup--code markup--li-code">O(n^2)</code></li>
<li name="dcc8" id="dcc8" class="graf graf--li graf-after--li">Worst Case Sort: Merge Sort: <code
class="markup--code markup--li-code">O(n^2)</code></li>
</ul>
<h4 name="8706" id="8706" class="graf graf--h4 graf-after--li">Space Complexity</h4>
<ul class="postList">
<li name="d841" id="d841" class="graf graf--li graf-after--h4">Worst Case: <code
class="markup--code markup--li-code">O(1)</code></li>
</ul>
<h4 name="e03b" id="e03b" class="graf graf--h4 graf-after--li">Visualization</h4>
<figure name="d7df" id="d7df" class="graf graf--figure graf-after--h4"><img class="graf-image"
data-image-id="0*SZSRoth1yRyxD4Z3.gif" data-width="100" data-height="371"
src="https://cdn-images-1.medium.com/max/800/0*SZSRoth1yRyxD4Z3.gif"></figure>
<p name="5bd1" id="5bd1" class="graf graf--p graf-after--figure"><a
href="https://en.wikipedia.org/wiki/Selection_sort"
data-href="https://en.wikipedia.org/wiki/Selection_sort" class="markup--anchor markup--p-anchor"
rel="noopener" target="_blank">(source: Wikipedia, <em class="markup--em markup--p-em">Insertion
Sort</em>)</a></p>
<h3 name="608a" id="608a" class="graf graf--h3 graf-after--p">Insertion Sort</h3>
<h4 name="358f" id="358f" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="fea5" id="fea5" class="graf graf--li graf-after--h4">A comparison based sorting algorithm.
</li>
<li name="b50e" id="b50e" class="graf graf--li graf-after--li">Iterates left to right comparing the
current cursor to the previous item.</li>
<li name="a9b1" id="a9b1" class="graf graf--li graf-after--li">If the cursor is smaller than the item on
the left it swaps positions and the cursor compares itself again to the left hand side until it is put
in its sorted position.</li>
<li name="9a90" id="9a90" class="graf graf--li graf-after--li">As the algorithm processes the data set,
the left side becomes increasingly sorted until it is fully sorted.</li>
<li name="6e36" id="6e36" class="graf graf--li graf-after--li">Changes the array in place.</li>
</ul>
<h4 name="84ef" id="84ef" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="bc6a" id="bc6a" class="graf graf--li graf-after--h4">Inefficient for large data sets, but can
be faster for than other algorithms for small ones.</li>
<li name="103c" id="103c" class="graf graf--li graf-after--li">Although it has an <code
class="markup--code markup--li-code">O(n^2)</code>, in practice it slightly less since its
comparison scheme only requires checking place if its smaller than its neighbor.</li>
</ul>
<h4 name="f5f5" id="f5f5" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="5b2a" id="5b2a" class="graf graf--li graf-after--h4">Best Case: <code
class="markup--code markup--li-code">O(n)</code></li>
<li name="415d" id="415d" class="graf graf--li graf-after--li">Average Case: <code
class="markup--code markup--li-code">O(n^2)</code></li>
<li name="b6b2" id="b6b2" class="graf graf--li graf-after--li">Worst Case: <code
class="markup--code markup--li-code">O(n^2)</code></li>
</ul>
<h4 name="d150" id="d150" class="graf graf--h4 graf-after--li">Space Complexity</h4>
<ul class="postList">
<li name="412f" id="412f" class="graf graf--li graf-after--h4">Worst Case: <code
class="markup--code markup--li-code">O(n)</code></li>
</ul>
<h4 name="f56a" id="f56a" class="graf graf--h4 graf-after--li">Visualization</h4>
<figure name="5c84" id="5c84" class="graf graf--figure graf-after--h4"><img class="graf-image"
data-image-id="0*Qh5uC4IwcxaZLNhy.gif" data-width="300" data-height="180"
src="https://cdn-images-1.medium.com/max/800/0*Qh5uC4IwcxaZLNhy.gif"></figure>
<p name="2d95" id="2d95" class="graf graf--p graf-after--figure"><a
href="https://en.wikipedia.org/wiki/Insertion_sort"
data-href="https://en.wikipedia.org/wiki/Insertion_sort" class="markup--anchor markup--p-anchor"
rel="noopener" target="_blank">(source: Wikipedia, <em class="markup--em markup--p-em">Insertion
Sort</em>)</a></p>
<h3 name="d656" id="d656" class="graf graf--h3 graf-after--p">Merge Sort</h3>
<h4 name="82f1" id="82f1" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="12cb" id="12cb" class="graf graf--li graf-after--h4">A divide and conquer algorithm.</li>
<li name="1472" id="1472" class="graf graf--li graf-after--li">Recursively divides entire array by half
into subsets until the subset is one, the base case.</li>
<li name="60bf" id="60bf" class="graf graf--li graf-after--li">Once the base case is reached results are
returned and sorted ascending left to right.</li>
<li name="e15a" id="e15a" class="graf graf--li graf-after--li">Recursive calls are returned and the
sorts double in size until the entire array is sorted.</li>
</ul>
<h4 name="2c78" id="2c78" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="0953" id="0953" class="graf graf--li graf-after--h4">This is one of the fundamental sorting
algorithms.</li>
<li name="6860" id="6860" class="graf graf--li graf-after--li">Know that it divides all the data into as
small possible sets then compares them.</li>
</ul>
<h4 name="0892" id="0892" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="363e" id="363e" class="graf graf--li graf-after--h4">Worst Case: <code
class="markup--code markup--li-code">O(n log n)</code></li>
<li name="6dc5" id="6dc5" class="graf graf--li graf-after--li">Average Case: <code
class="markup--code markup--li-code">O(n log n)</code></li>
<li name="4403" id="4403" class="graf graf--li graf-after--li">Best Case: <code
class="markup--code markup--li-code">O(n)</code></li>
</ul>
<h4 name="d333" id="d333" class="graf graf--h4 graf-after--li">Space Complexity</h4>
<ul class="postList">
<li name="76d6" id="76d6" class="graf graf--li graf-after--h4">Worst Case: <code
class="markup--code markup--li-code">O(1)</code></li>
</ul>
<h4 name="92b4" id="92b4" class="graf graf--h4 graf-after--li">Visualization</h4>
<figure name="1f31" id="1f31" class="graf graf--figure graf-after--h4"><img class="graf-image"
data-image-id="0*cnUTrzYJ3eu9juJP.png" data-width="400" data-height="385"
src="https://cdn-images-1.medium.com/max/800/0*cnUTrzYJ3eu9juJP.png"></figure>
<p name="25ee" id="25ee" class="graf graf--p graf-after--figure"><a
href="https://en.wikipedia.org/wiki/Merge_sort" data-href="https://en.wikipedia.org/wiki/Merge_sort"
class="markup--anchor markup--p-anchor" rel="noopener" target="_blank">(source: Wikipedia, <em
class="markup--em markup--p-em">Merge Sort</em>)</a></p>
<h3 name="e213" id="e213" class="graf graf--h3 graf-after--p">Quicksort</h3>
<h4 name="351c" id="351c" class="graf graf--h4 graf-after--h3">Definition</h4>
<ul class="postList">
<li name="96f7" id="96f7" class="graf graf--li graf-after--h4">A divide and conquer algorithm</li>
<li name="9440" id="9440" class="graf graf--li graf-after--li">Partitions entire data set in half by
selecting a random pivot element and putting all smaller elements to the left of the element and
larger ones to the right.</li>
<li name="a683" id="a683" class="graf graf--li graf-after--li">It repeats this process on the left side
until it is comparing only two elements at which point the left side is sorted.</li>
<li name="97f0" id="97f0" class="graf graf--li graf-after--li">When the left side is finished sorting it
performs the same operation on the right side.</li>
<li name="19aa" id="19aa" class="graf graf--li graf-after--li">Computer architecture favors the
quicksort process.</li>
<li name="8d41" id="8d41" class="graf graf--li graf-after--li">Changes the array in place.</li>
</ul>
<h4 name="55a9" id="55a9" class="graf graf--h4 graf-after--li">What you need to know</h4>
<ul class="postList">
<li name="f426" id="f426" class="graf graf--li graf-after--h4">While it has the same Big O as (or worse
in some cases) many other sorting algorithms it is often faster in practice than many other sorting
algorithms, such as merge sort.</li>
</ul>
<h4 name="1b3e" id="1b3e" class="graf graf--h4 graf-after--li">Time Complexity</h4>
<ul class="postList">
<li name="aa6c" id="aa6c" class="graf graf--li graf-after--h4">Worst Case: <code
class="markup--code markup--li-code">O(n^2)</code></li>
<li name="cac8" id="cac8" class="graf graf--li graf-after--li">Average Case: <code
class="markup--code markup--li-code">O(n log n)</code></li>
<li name="4676" id="4676" class="graf graf--li graf-after--li">Best Case: <code
class="markup--code markup--li-code">O(n log n)</code></li>
</ul>
<h4 name="d05b" id="d05b" class="graf graf--h4 graf-after--li">Space Complexity</h4>
<ul class="postList">
<li name="2a39" id="2a39" class="graf graf--li graf-after--h4">Worst Case: <code
class="markup--code markup--li-code">O(log n)</code></li>
</ul>
<h4 name="2507" id="2507" class="graf graf--h4 graf-after--li">Visualization</h4>
<figure name="ec61" id="ec61" class="graf graf--figure graf-after--h4"><img class="graf-image"
data-image-id="0*t5olHZSO0e1iVQH5.gif" data-width="280" data-height="214"
src="https://cdn-images-1.medium.com/max/800/0*t5olHZSO0e1iVQH5.gif"></figure>
<p name="e5e2" id="e5e2" class="graf graf--p graf-after--figure"><a
href="https://en.wikipedia.org/wiki/Quicksort" data-href="https://en.wikipedia.org/wiki/Quicksort"
class="markup--anchor markup--p-anchor" rel="noopener" target="_blank">(source: Wikipedia, <em
class="markup--em markup--p-em">Quicksort</em>)</a></p>
<h4 name="6e7e" id="6e7e" class="graf graf--h4 graf-after--p">Merge Sort Vs. Quicksort</h4>
<ul class="postList">
<li name="3798" id="3798" class="graf graf--li graf-after--h4">Quicksort is likely faster in practice,
but merge sort is faster on paper.</li>
<li name="4b98" id="4b98" class="graf graf--li graf-after--li">Merge Sort divides the set into the
smallest possible groups immediately then reconstructs the incrementally as it sorts the groupings.
</li>
<li name="f8db" id="f8db" class="graf graf--li graf-after--li">Quicksort continually partitions the data
set by a pivot, until the set is recursively sorted.</li>
</ul>
<h3 name="c1eb" id="c1eb" class="graf graf--h3 graf-after--li">Additional Resources</h3>
<p name="0274" id="0274" class="graf graf--p graf-after--h3"><a
href="https://www.khanacademy.org/computing/computer-science/algorithms"
data-href="https://www.khanacademy.org/computing/computer-science/algorithms"
class="markup--anchor markup--p-anchor" rel="noopener" target="_blank">Khan Academy’s Algorithm
Course</a></p>
<h3 name="713a" id="713a" class="graf graf--h3 graf-after--p">What is ARIA and when should you use it?
</h3>
<h4 name="3588" id="3588" class="graf graf--h4 graf-after--h3">Answer</h4>
<p name="b51b" id="b51b" class="graf graf--p graf-after--h4">ARIA stands for “Accessible Rich Internet
Applications”, and is a technical specification created by the World Wide Web Consortium (W3C). Better
known as WAI-ARIA, it provides additional HTML attributes in the development of web applications to
offer people who use assistive technologies (AT) a more robust and interoperable experience with dynamic
components. By providing the component’s role, name, and state, AT users can better understand how to
interact with the component. WAI-ARIA should only be used when an HTML element equivalent is not
available or lacks full browser or AT support. WAI-ARIA’s semantic markup coupled with JavaScript works
to provide an understandable and interactive experience for people who use AT.</p>
<p name="3e6a" id="3e6a" class="graf graf--p graf-after--p">An example using ARIA:</p>
<pre name="a97e" id="a97e"
class="graf graf--pre graf-after--p"><div <br> role="combobox"<br> aria-expanded="false"<br> aria-owns="ex1-grid"<br> aria-haspopup="grid"<br> id="ex1-combobox"><br> ...<br></div></pre>
<p name="5387" id="5387" class="graf graf--p graf-after--pre">Credit: W3C’s <a
href="https://w3c.github.io/aria-practices/examples/combobox/aria1.1pattern/grid-combo.html"
data-href="https://w3c.github.io/aria-practices/examples/combobox/aria1.1pattern/grid-combo.html"
class="markup--anchor markup--p-anchor" rel="noopener" target="_blank">ARIA 1.1 Combobox with Grid
Popup Example</a></p>
<h4 name="2ebf" id="2ebf" class="graf graf--h4 graf-after--p">Don’t forget:</h4>
<ul class="postList">
<li name="71c0" id="71c0" class="graf graf--li graf-after--h4">Accessible Rich Internet Applications
</li>
<li name="34be" id="34be" class="graf graf--li graf-after--li">Benefits people who use assistive
technologies (AT)</li>
<li name="af4a" id="af4a" class="graf graf--li graf-after--li">Provides role, name, and state</li>
<li name="fb7d" id="fb7d" class="graf graf--li graf-after--li">Semantic HTML coupled with JavaScript
</li>
</ul>
<p name="6f10" id="6f10" class="graf graf--p graf-after--li">Additional links</p>
<ul class="postList">
<li name="e4bb" id="e4bb" class="graf graf--li graf-after--p"><a
href="https://www.w3.org/WAI/standards-guidelines/aria/"
data-href="https://www.w3.org/WAI/standards-guidelines/aria/"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">WAI-ARIA Overview</a></li>
<li name="baf7" id="baf7" class="graf graf--li graf-after--li"><a href="https://www.w3.org/TR/wai-aria/"
data-href="https://www.w3.org/TR/wai-aria/" class="markup--anchor markup--li-anchor" rel="noopener"
target="_blank">WAI-ARIA Spec</a></li>
<li name="de2f" id="de2f" class="graf graf--li graf-after--li"><a href="https://youtu.be/4bH57rWPnYo"
data-href="https://youtu.be/4bH57rWPnYo" class="markup--anchor markup--li-anchor" rel="noopener"
target="_blank">ARIA Serious? Eric Eggert presentation</a></li>
</ul>
<h3 name="b946" id="b946" class="graf graf--h3 graf-after--li">What is the minimum recommended ratio of
contrast between foreground text and background to comply with WCAG? Why does this matter?</h3>
<h4 name="22a0" id="22a0" class="graf graf--h4 graf-after--h3">Answer</h4>
<p name="132c" id="132c" class="graf graf--p graf-after--h4">4.5:1 is the calculated contrast ratio
between foreground text and background that is recommended by the Web Content Accessibiity Guidelines
(WCAG) success criteria (SC) 1.4.3: Contrast (Minimum). This SC was written by the World Wide Web
Consortium (W3C) to ensure that people with low vision or color deficiencies are able to read (perceive)
important content on a web page. It goes beyond color choices to ensure text stands out on the
background it’s placed on.</p>
<h4 name="5be5" id="5be5" class="graf graf--h4 graf-after--p">Don’t forget:</h4>
<ul class="postList">
<li name="737f" id="737f" class="graf graf--li graf-after--h4">At least 4.5:1 contrast ratio between
foreground text and background</li>
<li name="df36" id="df36" class="graf graf--li graf-after--li">Benefits people with low vision or color
deficiencies</li>
</ul>
<p name="79f5" id="79f5" class="graf graf--p graf-after--li">Additional links</p>
<ul class="postList">
<li name="0d73" id="0d73" class="graf graf--li graf-after--p"><a
href="https://www.alaskawebdev.com/contact" data-href="https://www.alaskawebdev.com/contact"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">Understanding SC 1.4.3</a>
</li>
<li name="9a71" id="9a71" class="graf graf--li graf-after--li"><a
href="https://webaim.org/resources/contrastchecker/"
data-href="https://webaim.org/resources/contrastchecker/" class="markup--anchor markup--li-anchor"
rel="noopener" target="_blank">WebAIM Contrast Checker</a></li>
<li name="bab4" id="bab4" class="graf graf--li graf-after--li"><a href="https://contrast-ratio.com/#"
data-href="https://contrast-ratio.com/#" class="markup--anchor markup--li-anchor" rel="noopener"
target="_blank">Contrast Ratio checker</a></li>
</ul>
<h3 name="aa9f" id="aa9f" class="graf graf--h3 graf-after--li">What are some of the tools available to
test the accessibility of a website or web application?</h3>
<h4 name="0702" id="0702" class="graf graf--h4 graf-after--h3">Answer</h4>
<p name="444a" id="444a" class="graf graf--p graf-after--h4">There are multiple tools that can help you to
find for accessibility issues in your website or application.</p>
<p name="8397" id="8397" class="graf graf--p graf-after--p">Check for issues in your website:</p>
<ul class="postList">
<li name="3dcf" id="3dcf" class="graf graf--li graf-after--p">Lighthouse from Google, it provides an
option for accessibility testing, it will check for the compliance of different accessibility
standards and give you an score with details on the different issues</li>
<li name="b0f8" id="b0f8" class="graf graf--li graf-after--li">Axe Coconut from DequeLabs, it is a
Chrome extension that adds a tab in the Developer tools, it will check for accessibility issues and it
will classify them by severity and suggest possible solutions</li>
</ul>
<p name="3fb0" id="3fb0" class="graf graf--p graf-after--li">Check for issues in your code: * Jest Axe,
you can add unit tests for accessibility * React Axe, test your React application with the axe-core
accessibility testing library. Results will show in the Chrome DevTools console. *
eslint-plugin-jsx-a11y, pairing this plugin with an editor lint plugin, you can bake accessibility
standards into your application in real-time.</p>
<p name="b608" id="b608" class="graf graf--p graf-after--p">Check for individual issues: * Color Contrast
checkers * Use a screen reader * Use only keyboard to navigate your site</p>
<h4 name="3966" id="3966" class="graf graf--h4 graf-after--p">Don’t forget:</h4>
<ul class="postList">
<li name="bf27" id="bf27" class="graf graf--li graf-after--h4">None of the tools will replace manual
testing</li>
<li name="cb93" id="cb93" class="graf graf--li graf-after--li">Mention of different ways to test
accessibility</li>
</ul>
<p name="6c27" id="6c27" class="graf graf--p graf-after--li">Additional links</p>
<ul class="postList">
<li name="fc25" id="fc25" class="graf graf--li graf-after--p"><a
href="https://github.com/nickcolley/jest-axe" data-href="https://github.com/nickcolley/jest-axe"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">Jest Axe</a></li>
<li name="61d0" id="61d0" class="graf graf--li graf-after--li"><a href="https://www.w3.org/TR/wai-aria/"
data-href="https://www.w3.org/TR/wai-aria/" class="markup--anchor markup--li-anchor" rel="noopener"
target="_blank">eslint-plugin-jsx-a11y</a></li>
<li name="a9b8" id="a9b8" class="graf graf--li graf-after--li"><a
href="https://github.com/dequelabs/react-axe" data-href="https://github.com/dequelabs/react-axe"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">React axe</a></li>
<li name="cacb" id="cacb" class="graf graf--li graf-after--li"><a
href="http://romeo.elsevier.com/accessibility_checklist/"
data-href="http://romeo.elsevier.com/accessibility_checklist/"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">Accessibility Checklist</a>
</li>
</ul>
<h3 name="34da" id="34da" class="graf graf--h3 graf-after--li">What is the Accessibility Tree?</h3>
<h4 name="cb74" id="cb74" class="graf graf--h4 graf-after--h3">Answer</h4>
<p name="97aa" id="97aa" class="graf graf--p graf-after--h4">The Accessibility Tree is a structure
produced by the browser’s Accessibility APIs which provides accessibility information to assistive
technologies such as screen readers. It runs parallel to the DOM and is similar to the DOM API, but with
much fewer nodes, because a lot of that information is only useful for visual presentation. By writing
semantic HTML we can take advantage of this process in creating an accessible experience for our users.
</p>
<h4 name="ae89" id="ae89" class="graf graf--h4 graf-after--p">Don’t forget:</h4>
<ul class="postList">
<li name="805b" id="805b" class="graf graf--li graf-after--h4">Tree structure exposing information to
assistive technologies</li>
<li name="aae3" id="aae3" class="graf graf--li graf-after--li">Runs parallel to the DOM</li>
<li name="66a9" id="66a9" class="graf graf--li graf-after--li">Semantic HTML is essential in creating
accessible experiences</li>
</ul>
<p name="6202" id="6202" class="graf graf--p graf-after--li">Additional links</p>
<ul class="postList">
<li name="31ce" id="31ce" class="graf graf--li graf-after--p"><a
href="https://www.smashingmagazine.com/2015/03/web-accessibility-with-accessibility-api/"
data-href="https://www.smashingmagazine.com/2015/03/web-accessibility-with-accessibility-api/"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">Accessibility APIs</a></li>
</ul>
<h3 name="3527" id="3527" class="graf graf--h3 graf-after--li">What is the purpose of the <code
class="markup--code markup--h3-code">alt</code> attribute on images?</h3>
<h4 name="d106" id="d106" class="graf graf--h4 graf-after--h3">Answer</h4>
<p name="ba11" id="ba11" class="graf graf--p graf-after--h4">The <code
class="markup--code markup--p-code">alt</code> attribute provides alternative information for an image
if a user cannot view it. The <code class="markup--code markup--p-code">alt</code> attribute should be
used to describe any images except those which only serve a decorative purpose, in which case it should
be left empty.</p>
<h4 name="d3b5" id="d3b5" class="graf graf--h4 graf-after--p">Don’t forget:</h4>
<ul class="postList">
<li name="e90d" id="e90d" class="graf graf--li graf-after--h4">Decorative images should have an empty
<code class="markup--code markup--li-code">alt</code> attribute.</li>
<li name="5def" id="5def" class="graf graf--li graf-after--li">Web crawlers use <code
class="markup--code markup--li-code">alt</code> tags to understand image content, so they are
considered important for Search Engine Optimization (SEO).</li>
<li name="0dcd" id="0dcd" class="graf graf--li graf-after--li">Put the <code
class="markup--code markup--li-code">.</code> at the end of <code
class="markup--code markup--li-code">alt</code> tag to improve accessibility.</li>
</ul>
<p name="9ec2" id="9ec2" class="graf graf--p graf-after--li">Additional links</p>
<ul class="postList">
<li name="759c" id="759c" class="graf graf--li graf-after--p"><a
href="https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML"
data-href="https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">A good basis for
accessibility</a></li>
</ul>
<h3 name="ec6a" id="ec6a" class="graf graf--h3 graf-after--li">What are <code
class="markup--code markup--h3-code">defer</code> and <code
class="markup--code markup--h3-code">async</code> attributes on a <code
class="markup--code markup--h3-code"><script></code> tag?</h3>
<h4 name="2dde" id="2dde" class="graf graf--h4 graf-after--h3">Answer</h4>
<p name="4812" id="4812" class="graf graf--p graf-after--h4">If neither attribute is present, the script
is downloaded and executed synchronously, and will halt parsing of the document until it has finished
executing (default behavior). Scripts are downloaded and executed in the order they are encountered.</p>
<p name="2c1f" id="2c1f" class="graf graf--p graf-after--p">The <code
class="markup--code markup--p-code">defer</code> attribute downloads the script while the document is
still parsing but waits until the document has finished parsing before executing it, equivalent to
executing inside a <code class="markup--code markup--p-code">DOMContentLoaded</code> event listener.
<code class="markup--code markup--p-code">defer</code> scripts will execute in order.</p>
<p name="fb7c" id="fb7c" class="graf graf--p graf-after--p">The <code
class="markup--code markup--p-code">async</code> attribute downloads the script during parsing the
document but will pause the parser to execute the script before it has fully finished parsing. <code
class="markup--code markup--p-code">async</code> scripts will not necessarily execute in order.</p>
<p name="36a6" id="36a6" class="graf graf--p graf-after--p">Note: both attributes must only be used if the
script has a <code class="markup--code markup--p-code">src</code> attribute (i.e. not an inline script).
</p>
<pre name="98d9" id="98d9"
class="graf graf--pre graf-after--p"><code class="markup--code markup--pre-code"><script src="myscript.js"></script><br><script src="myscript.js" defer></script><br><script src="myscript.js" async></script></code></pre>
<h4 name="6fd3" id="6fd3" class="graf graf--h4 graf-after--pre">Don’t forget:</h4>
<ul class="postList">
<li name="8457" id="8457" class="graf graf--li graf-after--h4">Placing a <code
class="markup--code markup--li-code">defer</code> script in the <code
class="markup--code markup--li-code"><head></code> allows the browser to download the script
while the page is still parsing, and is therefore a better option than placing the script before the
end of the body.</li>
<li name="a364" id="a364" class="graf graf--li graf-after--li">If the scripts rely on each other, use
<code class="markup--code markup--li-code">defer</code>.</li>
<li name="ebb2" id="ebb2" class="graf graf--li graf-after--li">If the script is independent, use <code
class="markup--code markup--li-code">async</code>.</li>
<li name="067e" id="067e" class="graf graf--li graf-after--li">Use <code
class="markup--code markup--li-code">defer</code> if the DOM must be ready and the contents are not
placed within a <code class="markup--code markup--li-code">DOMContentLoaded</code> listener.</li>
</ul>
<p name="2adf" id="2adf" class="graf graf--p graf-after--li">Additional links</p>
<ul class="postList">
<li name="fb64" id="fb64" class="graf graf--li graf-after--p"><a
href="http://www.growingwiththeweb.com/2014/02/async-vs-defer-attributes.html"
data-href="http://www.growingwiththeweb.com/2014/02/async-vs-defer-attributes.html"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">async vs defer
attributes</a></li>
</ul>
<h3 name="a936" id="a936" class="graf graf--h3 graf-after--li">What is an <code
class="markup--code markup--h3-code">async</code> function?</h3>
<pre name="bd04" id="bd04"
class="graf graf--pre graf-after--h3">async function foo() {<br> ...<br>}</pre>
<h4 name="a1f8" id="a1f8" class="graf graf--h4 graf-after--pre">Answer</h4>
<p name="acc6" id="acc6" class="graf graf--p graf-after--h4">An <code
class="markup--code markup--p-code">async</code> function is a function that allows you to pause the
function's execution while it waits for (<code class="markup--code markup--p-code">await</code>s) a
promise to resolve. It's an abstraction on top of the Promise API that makes asynchronous operations
<em class="markup--em markup--p-em">look</em> like they're synchronous.</p>
<p name="0327" id="0327" class="graf graf--p graf-after--p"><code
class="markup--code markup--p-code">async</code> functions automatically return a Promise object.
Whatever you <code class="markup--code markup--p-code">return</code> from the <code
class="markup--code markup--p-code">async</code> function will be the promise's <em
class="markup--em markup--p-em">resolution</em>. If instead you <code
class="markup--code markup--p-code">throw</code> from the body of an <code
class="markup--code markup--p-code">async</code> function, that will be how your async function <em
class="markup--em markup--p-em">rejects</em> the promise it returns.</p>
<p name="116a" id="116a" class="graf graf--p graf-after--p">Most importantly, <code
class="markup--code markup--p-code">async</code> functions are able to use the <code
class="markup--code markup--p-code">await</code> keyword in their function body, which <strong
class="markup--strong markup--p-strong">pauses the function</strong> until the operation after the
<code class="markup--code markup--p-code">await</code> completes, and allows it to return that
operation's result to a variable synchronously.</p>
<pre name="76b7" id="76b7"
class="graf graf--pre graf-after--p">// Normal promises in regular function:<br>function foo() {<br> promiseCall()<br> .then(result => {<br> // do something with the result<br> })<br>}</pre>
<pre name="eed8" id="eed8"
class="graf graf--pre graf-after--pre">// async functions<br>async function foo() {<br> const result = await promiseCall()<br> // do something with the result<br>}</pre>
<h4 name="cc26" id="cc26" class="graf graf--h4 graf-after--pre">Don’t forget:</h4>
<ul class="postList">
<li name="02ed" id="02ed" class="graf graf--li graf-after--h4"><code
class="markup--code markup--li-code">async</code> functions are just syntactic sugar on top of
Promises.</li>
<li name="895a" id="895a" class="graf graf--li graf-after--li">They make asynchronous operations look
like synchronous operations in your function.</li>
<li name="733b" id="733b" class="graf graf--li graf-after--li">They implicitly return a promise which
resolves to whatever your <code class="markup--code markup--li-code">async</code> function returns,
and reject to whatever your <code class="markup--code markup--li-code">async</code> function <code
class="markup--code markup--li-code">throw</code>s.</li>
</ul>
<p name="c685" id="c685" class="graf graf--p graf-after--li">Additional links</p>
<ul class="postList">
<li name="e1c0" id="e1c0" class="graf graf--li graf-after--p"><a
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function"
data-href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">MDN Docs — async
function</a></li>
<li name="bc69" id="bc69" class="graf graf--li graf-after--li"><a
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await"
data-href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await"
class="markup--anchor markup--li-anchor" rel="noopener" target="_blank">MDN Docs — await</a></li>
</ul>
<h3 name="5e8a" id="5e8a" class="graf graf--h3 graf-after--li">Create a function <code