-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproject_02.html
More file actions
955 lines (898 loc) · 31.1 KB
/
project_02.html
File metadata and controls
955 lines (898 loc) · 31.1 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<title>Slides</title>
<link rel="stylesheet" href="dist/reset.css" />
<link rel="stylesheet" href="dist/reveal.css" />
<link rel="stylesheet" href="dist/theme/project_02.css" />
<!-- Theme used for syntax highlighted code -->
<link rel="stylesheet" href="plugin/highlight/equilibrium-gray-light.css" />
</head>
<body>
<div class="reveal">
<div class="slides">
<!-- Project 02 -->
<section>
<h1>SC2001 Project 02</h1>
<p>Dijkstra's Algorithm</p>
<p><b>Team 5</b></p>
</section>
<section>
<h2>Setup</h2>
</section>
<section>
<p>
To facilitate subsequent implementation, we initialize the following
global variables.
</p>
<pre>
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
using ll = long long;
using ill = pair<int, ll>;
using lli = pair<ll, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution w_dist(1, 1'000'000'000); // [INFO] edge weight
int n, m;
constexpr ll INF = 1'000'000'000'000'000'000LL;
vector<vector<ll>> adm;
vector<vector<ill>> adj;
vector<ll> d, s;
</script>
</code>
</pre>
</section>
<section>
<p>
To generate a random graph, we present the following lambda
function.
</p>
<pre>
<code data-line-numbers="2|3-5|6-8|9-14|1-15" data-trim data-noescape class="cpp">
<script type="text/template">
auto gen_graph = [&](int n, int m, bool gen_adm, bool gen_adj) -> void {
assert(m <= n * n);
::n = n, ::m = m;
if (gen_adm) adm.assign(n, vector<ll>(n, INF));
if (gen_adj) adj.assign(n, vector<ill>());
vector<int> ed(m), ws(m), rg(n * n);
rgs::iota(rg, 0);
rgs::sample(rg, begin(ed), m, gen);
for (int i = 0; i < m; i++) {
int u = ed[i] / n, v = ed[i] % n;
ws[i] = w_dist(gen);
if (gen_adm) adm[u][v] = ws[i];
if (gen_adj) adj[u].emplace_back(v, ws[i]);
}
};
</script>
</code>
</pre>
<blockquote>
To debug/print the graph, we use a few other auxiliary lambda
functions.
</blockquote>
</section>
<section>
<h2>Part (a)</h2>
</section>
<section data-auto-animate>
<p>
Using an array as a priority queue is rather ambiguous phrasing...
For now, we'll interpret it as using the distance array directly as
the priority queue, i.e., we'll iterate through the array in
$\mathcal{O}(V)$ to determine the next <i>unvisited</i> node with
the <i>smallest distance</i>.
</p>
</section>
<section data-auto-animate>
<p>
Using an array as a priority queue is rather ambiguous phrasing...
For now, we'll interpret it as using the distance array directly as
the priority queue, i.e., we'll iterate through the array in
$\mathcal{O}(V)$ to determine the next <i>unvisited</i> node with
the <i>smallest distance</i>.
</p>
<pre>
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
auto get_min = [&]() -> int {
int idx = -1;
ll cur = INF;
for (int i = 0; i < n; i++) {
if (!s[i] && d[i] < cur) {
idx = i, cur = d[i];
}
}
return idx;
};
auto is_empty = [&]() -> int { return get_min() == -1; };
</script>
</code>
</pre>
</section>
<section>
<p>
Having established the necessary API for using an array as a
priority queue, we present the following implementation.
</p>
<pre>
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
auto imp_a = [&]() -> void {
d.assign(n, INF);
s.assign(n, false);
d[0] = 0;
while (!is_empty()) {
int i = get_min();
s[i] = true;
for (int j = 0; j < n; j++) {
if (i == j || adm[i][j] == INF) continue;
d[j] = min(d[j], d[i] + adm[i][j]);
}
}
};
</script>
</code>
</pre>
<blockquote>
Note that each node is visited just <b>once</b> (outer loop).
Retrieval of the next node (<b>get_min</b>), checking if the
priority queue is empty (<b>is_empty</b>), and iterating through
every node in the inner loop costs $\mathcal{O}(V)$, producing a
total time complexity of $\mathcal{O}(V \cdot (3V)) =
\mathcal{O}(V^2)$.
</blockquote>
</section>
<section>
<p>
Next, we'll count the number of operations taken on complete graphs
of varying V.
</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_i_n.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Operations", "display": true
}
},
"x": {
"title": {
"text": "V", "display": true
}
}
}
}
}
-->
</canvas>
</div>
</section>
<section>
<p>What if we set E to 500?</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_i_n_m_500.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Operations", "display": true
}
},
"x": {
"title": {
"text": "V", "display": true
}
}
}
}
}
-->
</canvas>
</div>
</section>
<section>
When E is small, relative to V, there is a high chance of producing a
<i>disconnected</i> graph, i.e., Dijkstra's would terminate before
inspecting every node, resulting in much fewer than V² operations.
</section>
<section>
<p>
Now, consider varying E from 0 to 10,000 while keeping V constant at
500.
</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_i_m.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Operations", "display": true
}
},
"x": {
"title": {
"text": "E", "display": true
}
}
}
}
}
-->
</canvas>
</div>
<blockquote>
Observe that when E is sufficiently large to produce a connected
graph with high probability, it no longer affects the time
complexity.
</blockquote>
</section>
<section>
<h2>Part (b)</h2>
</section>
<section>
<p>
Observe that the classic Dijkstra described in the lecture
<i>cannot</i>
be implemented using a minimizing heap since it requires the
deletion of non-minimum items within the heap...
</p>
<blockquote>
Such an operation would require $\mathcal{O}(V)$ time.
</blockquote>
</section>
<section>
Therefore, some kind of self-balancing tree is usually employed
instead.
<pre>
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
auto imp_b_ori = [&]() -> void {
d.assign(n, INF);
set<lli> pq;
d[0] = 0, pq.emplace(d[0], 0);
for (int u = 1; u < n; u++) pq.emplace(INF, u);
while (!empty(pq)) {
auto [cur, u] = *begin(pq);
pq.erase(begin(pq));
for (auto &[v, w] : adj[u]) {
if (w == INF || d[u] + w >= d[v]) continue;
pq.erase({ d[v], v });
d[v] = d[u] + w;
pq.emplace(d[v], v);
}
}
};
</script>
</code>
</pre>
</section>
<section>
Fortunately, Dijkstra's algorithm also has a modified form that
leverages the <b>lazy deletion</b> technique. This can be done with a
minimizing heap, as required in the problem.
</section>
<section>
<p>
By default, C++'s heap is a maximizing heap; to get a
<b>minimizing heap</b>, we can specify the following template
parameters.
</p>
<pre>
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
priority_queue<lli, vector<lli>, greater<>> pq;
</script>
</code>
</pre>
<blockquote>
If you happen to forget the syntax, a common trick is to invert all
edge weights/distances...
</blockquote>
</section>
<section data-auto-animate>
<p>First, let's examine a common mistake in the implementation.</p>
<pre data-id="animate-code">
<code data-line-numbers="2-4|5-6|7-15|1-16" data-trim data-noescape class="cpp">
<script type="text/template">
auto imp_b_bad = [&]() -> void {
d.assign(n, INF);
priority_queue<lli, vector<lli>, greater<>> pq;
d[0] = 0;
pq.emplace(0, 0);
for (int u = 1; u < n; u++) pq.emplace(INF, u);
while (!empty(pq)) {
auto [cur, u] = pq.top();
pq.pop();
for (auto &[v, w] : adj[u]) {
if (w == INF || d[u] + w >= d[v]) continue;
d[v] = d[u] + w;
pq.emplace(d[v], v);
}
}
};
</script>
</code>
</pre>
</section>
<section data-auto-animate>
<p>First, let's examine a common mistake in the implementation.</p>
<pre data-id="animate-code">
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
auto imp_b_bad = [&]() -> void {
d.assign(n, INF);
priority_queue<lli, vector<lli>, greater<>> pq;
d[0] = 0;
pq.emplace(0, 0);
for (int u = 1; u < n; u++) pq.emplace(INF, u);
while (!empty(pq)) {
auto [cur, u] = pq.top();
pq.pop();
for (auto &[v, w] : adj[u]) {
if (w == INF || d[u] + w >= d[v]) continue;
d[v] = d[u] + w;
pq.emplace(d[v], v);
}
}
};
</script>
</code>
</pre>
<blockquote>
Unfortunately, it passed only 15/23 test cases on CSES's Shortest
Routes I, while receiving the TLE verdict on the remaining 8 test
cases.
</blockquote>
</section>
<section>
<p>
Notice that in this edge case, the heap can contain up to
$\mathcal{O}(V^2)$ elements, each of which take $\mathcal{O}(V)$
operations to process, leading to an awful $\mathcal{O}(V^3)$ time
complexity.
</p>
<pre data-id="animate-code">
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
auto gen_break_b_bad = [&](int n) -> void {
// 0: I n 2*n 3*n 4*n 5*n ...
// 1: n I (n-1) 2*(n-1) 3*(n-1) 4*(n-1) ...
// 2: 2*n (n-1) I (n-2) 2*(n-1) 3*(n-1) ...
// ...
::n = n, ::m = (n - 1) * n / 2;
adm.assign(n, vector<ll>(n, INF));
adj.assign(n, vector<ill>());
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
ll w = (ll)(n - i) * (j - i);
adm[i][j] = adm[j][i] = w;
adj[i].emplace_back(j, w), adj[j].emplace_back(i, w);
}
}
};
</script>
</code>
</pre>
</section>
<section>
Observe that we don't need to insert all nodes at the start, and we
also need to perform a check to guarantee that the current node is the
most recently updated one (i.e., minimum distance).
</section>
<section>
<p>
This implementation receives the AC verdict on CSES's Shortest
Routes I.
</p>
<pre>
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
auto imp_b_opt = [&]() -> void {
d.assign(n, INF);
priority_queue<lli, vector<lli>, greater<>> pq;
d[0] = 0;
pq.emplace(0, 0);
while (!empty(pq)) {
auto [cur, u] = pq.top();
pq.pop();
if (cur != d[u]) continue;
for (auto &[v, w] : adj[u]) {
if (w == INF || d[u] + w >= d[v]) continue;
d[v] = d[u] + w;
pq.emplace(d[v], v);
}
}
};
</script>
</code>
</pre>
</section>
<section data-auto-animate>
<p>
Observe that the initial assignment to the distance array costs
$\mathcal{O}(V)$ time, and for each possible "improvement" in
distance, our heap size is incremented by one. There can be
$\mathcal{O}(E)$ such improvements, and each heap operation can take
up to $\mathcal{O}(\log_2 E)$ time. Therefore, the total time
complexity is $\mathcal{O}(V + E \cdot \log_2 E)$.
</p>
</section>
<section data-auto-animate>
<p>
Observe that the initial assignment to the distance array costs
$\mathcal{O}(V)$ time, and for each possible "improvement" in
distance, our heap size is incremented by one. There can be
$\mathcal{O}(E)$ such improvements, and each heap operation can take
up to $\mathcal{O}(\log_2 E)$ time. Therefore, the total time
complexity is $\mathcal{O}(V + E \cdot \log_2 E)$.
</p>
<blockquote>
Since $E \leq V^2$, another valid representation is $\mathcal{O}(V +
E \cdot \log_2 V^2)$ = $\mathcal{O}(V + E \cdot \log_2 V)$
</blockquote>
</section>
<section>
<p>
By varying V and keeping E at 2,500, we obtained the following
results.
</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_ii_n.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Operations", "display": true
}
},
"x": {
"title": {
"text": "V", "display": true
}
}
}
}
}
-->
</canvas>
</div>
<blockquote>
In practice, it is rarely the case that every edge improves the
distance (worst case assumption).
</blockquote>
</section>
<section>
<p>Next, we'll fix V at 1,000 and vary E.</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_ii_m.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Operations", "display": true
}
},
"x": {
"title": {
"text": "E", "display": true
}
}
}
}
}
-->
</canvas>
</div>
</section>
<section>
<p>
Finally, let's consider the edge case mentioned earlier where every
edge leads to an insertion.
</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_ii_edge.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Operations", "display": true
}
},
"x": {
"title": {
"text": "E", "display": true
}
}
}
}
}
-->
</canvas>
</div>
</section>
<section>
<h2>Part (c)</h2>
</section>
<section>
<p>
In terms of memory, one of the major drawbacks of adjacency matrices
is the $\mathcal{O}(V^2)$ memory that it requires compared to to the
$\mathcal{O}(V + E)$ memory for adjacency lists.
</p>
<p>
This is very inefficient for <b>sparse graphs</b> and on many
problems where $V \leq 10^5$, you wouldn't even be able to allocate
enough memory without getting a segmentation fault.
</p>
</section>
<section data-auto-animate>
<p>
In terms of time complexity, $\mathcal{O}(V + E \cdot \log_2 E)$ is
better than $\mathcal{O}(V^2)$ under most circumstances.
</p>
</section>
<section data-auto-animate>
<p>
In terms of time complexity, $\mathcal{O}(V + E \cdot \log_2 E)$ is
better than $\mathcal{O}(V^2)$ under most circumstances.
</p>
<blockquote>
However, when $E \approx V^2$ (e.g., complete graph), the former
evolves into $\mathcal{O}(V^2 \cdot \log_2 V)$, which is inferior to
$\mathcal{O}(V^2)$. Therefore, in such cases, we'd prefer part (a)'s
implementation.
</blockquote>
</section>
<section>
<p>
First, let's vary V while keeping E at 500. Notice that part (b)'s
implementation is generally preferable except for small V where part
(a)'s implementation performs slightly better.
</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_iii_n.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Runtime (ms)", "display": true
}
},
"x": {
"title": {
"text": "V", "display": true
}
}
}
}
}
-->
</canvas>
</div>
</section>
<section>
<p>
On complete graphs, it is evident that the logarithmic factor
results in part (b)'s implementation being slightly slower.
</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_iii_complete.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Runtime (ms)", "display": true
}
},
"x": {
"title": {
"text": "V", "display": true
}
}
}
}
}
-->
</canvas>
</div>
</section>
<section>
<p>
Finally, we'd like to offer another interpretation of "using an
array as a priority queue". Instead of iterating over the distance
array in $\mathcal{O}(V)$, let's construct a <b>segment tree</b>
instead.
</p>
<pre>
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
class SegTree {
int n;
vector<lli> a, tree;
void build(int i, int l, int r) {
if (l == r) tree[i] = a[l];
else {
int m = (l + r) / 2;
build(2 * i, l, m);
build(2 * i + 1, m + 1, r);
tree[i] = conquer(tree[2 * i], tree[2 * i + 1]);
}
}
void update(int i, int tl, int tr, int pos, lli val) {
if (tl == tr) tree[i] = val;
else {
int tm = (tl + tr) / 2;
if (pos <= tm) update(2 * i, tl, tm, pos, val);
else update(2 * i + 1, tm + 1, tr, pos, val);
tree[i] = conquer(tree[2 * i], tree[2 * i + 1]);
}
}
lli query(int i, int tl, int tr, int l, int r) {
if (l > r) return { INF, -1 };
if (l == tl && r == tr) return tree[i];
int tm = (tl + tr) / 2;
return conquer(
query(2 * i, tl, tm, l, min(r, tm)),
query(2 * i + 1, tm + 1, tr, max(l, tm + 1), r));
}
public:
SegTree(vector<lli> &a)
: a(a) {
n = ssize(a);
tree.assign(4 * n, {});
build(1, 0, n - 1);
}
lli conquer(lli x, lli y) { return min(x, y); }
void update(int pos, lli val) { update(1, 0, n - 1, pos, val); }
lli query(int l, int r) { return query(1, 0, n - 1, l, r); }
};
</script>
</code>
</pre>
</section>
<section>
Both point updates and range queries cost $\mathcal{O}(\log_2 V)$, and
it could be used as a priority queue in place of a binary heap.
<pre>
<code data-line-numbers data-trim data-noescape class="cpp">
<script type="text/template">
auto imp_b_seg = [&]() -> void {
d.assign(n, INF), d[0] = 0;
vector<lli> _(n);
for (int i = 1; i < n; i++) _[i] = { INF, i };
SegTree pq(_);
while (pq.query(0, n - 1).first != INF) {
auto [cur, u] = pq.query(0, n - 1);
pq.update(u, { INF, u });
if (cur != d[u]) continue;
for (auto &[v, w] : adj[u]) {
if (w == INF || d[u] + w >= d[v]) continue;
d[v] = d[u] + w;
pq.update(v, { d[v], v });
}
}
};
</script>
</code>
</pre>
<blockquote>
Note that part (a)'s algorithm is still $\mathcal{O}(V^2)$ because
for every node, we still have to iterate over $\mathcal{O}(V)$ other
nodes in the inner loop.
</blockquote>
</section>
<section>
<p>
Just as we did earlier, let's vary V while keeping E at 500. Notice
that the segment tree offers a tiny speedup as more often than not,
$\mathcal{O}(\log_2 (V))$ is better than $\mathcal{O}(\log_2 (E))$.
</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_iii_n_seg.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Runtime (ms)", "display": true
}
},
"x": {
"title": {
"text": "V", "display": true
}
}
}
}
}
-->
</canvas>
</div>
</section>
<section>
<p>
On complete graphs, the difference in logarithmic factors is even
more obvious.
</p>
<div>
<canvas
data-chart="line"
data-chart-src="project_02/part_iii_complete_seg.txt"
style="height: 45vh"
>
<!--
{
"options": {
"animation": false,
"scales": {
"y": {
"title": {
"text": "Runtime (ms)", "display": true
}
},
"x": {
"title": {
"text": "V", "display": true
}
}
}
}
}
-->
</canvas>
</div>
</section>
<section>
<h1>Thank You</h1>
<blockquote>
<a href="https://github.com/anAcc22/SC2001_Group_Project">
https://github.com/anAcc22/SC2001_Group_Project
</a>
</blockquote>
</section>
<section>
<h3>References</h3>
<ul style="font-size: 26px">
<li>
Halim, S., Halim, F., & Effendy, S. (2020). Competitive
programming 4: The lower bound of programming contests in the
2020s. book 1 Chapter 1-4. Lulu.com.
</li>
<li>
Segment tree. Segment Tree - Algorithms for Competitive
Programming. (2023, December 20).
https://cp-algorithms.com/data_structures/segment_tree.html
</li>
</ul>
</section>
</div>
</div>
<script src="dist/reveal.js"></script>
<script src="plugin/notes/notes.js"></script>
<script src="plugin/math/math.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<!-- Chart Plugin -->
<script src="https://cdn.jsdelivr.net/npm/reveal.js-plugins@latest/chart/plugin.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.2.0/chart.min.js"></script>
<script>
// More info about initialization & config:
// - https://revealjs.com/initialization/
// - https://revealjs.com/config/
Chart.defaults.font.family = "Maple Mono";
Chart.defaults.font.size = 16;
Reveal.initialize({
hash: true,
transition: "slide",
autoAnimateDuration: 0.8,
maxScale: 1.0, // PERF: resolves blurry font issue
minScale: 0.2,
chart: {
defaults: {
color: "#121212",
scale: {
grid: {
color: "#424242",
},
},
},
line: {
borderColor: ["#447754d1", "#824232d1", "#826222d1", "#6687b1"],
borderDash: [
[0, 0],
[0, 0],
],
},
scatter: {
borderColor: ["#447754d1", "#824232d1", "#826222d1", "#6687b1"],
backgroundColor: ["#447754d1", "#824232d1", "#826222d1", "#6687b1"],
borderDash: [
[0, 0],
[0, 0],
[0, 0],
],
pointRadius: [1, 1, 1],
},
},
// Learn about plugins: https://revealjs.com/plugins/
plugins: [
RevealMarkdown,
RevealHighlight,
RevealNotes,
RevealChart,
RevealMath.KaTeX,
],
});
</script>
</body>
</html>