forked from gcallah/algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GreedyAlgorithms.html
1146 lines (1070 loc) · 44.6 KB
/
GreedyAlgorithms.html
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
<html>
<!-- THIS FILE WAS GENERATED BY A SCRIPT: DO NOT EDIT IT! -->
<head>
<link href="style.css" rel="stylesheet" type="text/css"/>
<title>
Design and Analysis of Algorithms: Greedy Algorithms
</title>
</head>
<body>
<div id="header">
<div id="logo">
<img src="graphics/Julia.png">
</div>
<div id="user-tools">
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="feedback.html">Feedback</a>
</div>
</div>
<h1>
Design and Analysis of Algorithms: Greedy Algorithms
</h1>
<div style="text-align:center">
<p>
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/The_worship_of_Mammon.jpg/170px-The_worship_of_Mammon.jpg">
<br>
</p>
</div>
<details>
<summary class="sum1">
A family of problems and approriate solutions
</summary>
<p>
It is important to recognize that we have been
dealing with a family of problems and solutions
to those problems:
</p>
<ul>
<li><b>Optimal substructure</b>:
<br>Recursive solution.
</li>
<li><b>Optimal substructure with overlapping sub-problems</b>:
<br>Recursion with memoization or dynamic programming.
</li>
<li>
<b>Optimal substructure where only the
locally optimal choice matters</b>:
<br>Greedy algorithms.
</li>
</ul>
</details>
<details>
<summary class="sum1">
What is a greedy algorithm?
</summary>
<p>
We have an optimization problem.
<br>
At each step of the algorithm, we have to make a choice, e.g.,
cut the rod here, or cut it there.
<br>
Sometimes, we need to calculate the result of all possible
choices.
</p>
<ul>
<li>When we do so from the top down, we have a <i>recursive
algorithm</i>. A naive recursive algorithm may be very
expensive, but we can significantly reduce its run-time by
<i>memoizing</i> it.
</li>
<li>When we do this calculation from the bottom up, we are
employing <i>dynamic programming</i>.
</li>
</ul>
<p>
But sometimes, we can do much better than either of those
choices. Sometimes, we don't need to consider the global
situation at all: we can simply make the best choice among the
options provided by the local problem we face, and then
continue that procedure for all subsequent local problems.
<br>
<br>
An algorithm that operates in such a fashion is a <i>greedy
algorithm</i>. (The name comes from the idea that the
algorithm <i>greedily</i> grabs the best choice available to it right
away.)
<br>
<br>
Clearly, not all problems can be solved by greedy algorithms.
Consider this simple shortest path problem:
<br>
<br>
<img src="graphics/ShortPath.png"
height="240" width="360">
<br>
<br>
A greedy algorithm choosing the shortest path from <i>a</i> to <i>d</i> will
wrongly head to <i>b</i> first, rather than to <i>c</i>.
</p>
<figure>
<iframe width="560" height="315"
src="https://www.youtube.com/embed/rOOyJNgyW_o"
frameborder="0" allowfullscreen></iframe>
<figcaption>
Introduction to greedy algorithms
</figcaption>
</figure>
</details>
<details>
<summary class="sum1">
An activity selection problem
</summary>
<p>
Suppose we need to schedule a lecture hall with the goal of
maximizing the number of lectures it can hold, given the
constraint that no lectures can share the space.
<br>
We have the activities sorted in order of increasing finish
time:
<br>
<i>f<sub>1</sub> ≤ f<sub>2</sub> ≤ f<sub>3</sub>
≤ ... ≤ f<sub>n - 1</sub> ≤ f<sub>n</sub></i>.
<br>
<br>
We might have the following set of activities:
</p>
<table>
<tr>
<th>
<i>i</i>
</th>
<th>
1
</th>
<th>
2
</th>
<th>
3
</th>
<th>
4
</th>
<th>
5
</th>
<th>
6
</th>
<th>
7
</th>
<th>
8
</th>
<th>
9
</th>
<th>
10
</th>
<th>
11
</th>
</tr>
<tr>
<th>
<i>s<sub>i</sub></i>
</th>
<td>
1
</td>
<td>
3
</td>
<td>
0
</td>
<td>
5
</td>
<td>
3
</td>
<td>
5
</td>
<td>
6
</td>
<td>
8
</td>
<td>
8
</td>
<td>
2
</td>
<td>
12
</td>
</tr>
<tr>
<th>
<i>f<sub>i</sub></i>
</th>
<td>
4
</td>
<td>
5
</td>
<td>
6
</td>
<td>
7
</td>
<td>
9
</td>
<td>
9
</td>
<td>
10
</td>
<td>
11
</td>
<td>
12
</td>
<td>
14
</td>
<td>
16
</td>
</tr>
</table>
<p>
<br>
We have several sets of mutually compatible lectures, e.g.:
<br>
{<i>a</i><sub>3</sub>,
<i>a</i><sub>9</sub>,
<i>a</i><sub>11</sub>}
<br>
However, this set is larger:
<br>
{<i>a</i><sub>1</sub>,
<i>a</i><sub>4</sub>,
<i>a</i><sub>8</sub>,
<i>a</i><sub>11</sub>}
<br>
<br>
How do we find the maximum subset of lectures we can
schedule?
</p>
<details>
<summary class="sum2">
The optimal sub-structure of the problem
</summary>
<p>
It is easy to see that the problem exhibits optimal
substructure. <i>If</i> the optimal solution includes a
lecture from 4 to 6, then we have the sub-problems of
scheduling lectures that end by 4, and lectures that start
at 6 or after. Obviously, we must solve each of those
sub-problems in an optimal way, or our solution will not be
optimal! (Think of our problem of traveling from MetroTech
Center to Yankee Stadium via Grand Central.) Our textbook
calls this a "cut-and-paste" argument: we can cut an
optimal set of lectures ending by 4 and paste it into our
supposed optimal solution: if the solution was different
before 4, we have improved it, so it wasn't actually
optimal!
<br>
<br>
It is straight forward to see that we
can solve this problem with a recursive,
memoized algorithm -- we examine each
possible "cut" of a "middle" lecture, and recursively solve
the start-to-middle problem, and the middle-to-end problem.
Or we could use a bottom-up dynamic programming algorithm,
developed from the recursive solution in the same way we
saw in our last lecture.
</p>
</details>
<details>
<summary class="sum2">
Making the greedy choice
</summary>
<p>
But we can solve this problem much more efficiently. At
each step in solving it, we can make a completely <i>local</i>
choice: what activity (still possible) finishes earliest?
<br>
<br>
Since we have sorted the activities in order of increasing
finish time, we simply choose <i>a</i><sub>1</sub>, since
it is guaranteed to finish at least tied for first.
<br>
<br>
The proof that this will give us a maximal set of
activities is trivial: Let us suppose <i>a</i><sub>j</sub>
is the activity in some set that finishes first, but that
there is a maximal subset A<sub>k</sub>
that does <i>not</i> include
<i>a</i><sub>j</sub>. We simply remove the first element of
A<sub>k</sub> and substitute in <i>a</i><sub>j</sub>. This
is guaranteed to be a compatible set of activities, since
<i>a</i><sub>j</sub> finishes first, and it will be
maximal, since it is the same size as A<sub>k</sub>. (Note
that the textbook offers us an example of such sets on page
415.)
</p>
</details>
<details>
<summary class="sum2">
A recursive greedy algorithm
</summary>
<p>
The algorithm is straightforward:
find the first compatible activity, then call
the algorithm again with the rest of the activity list.
<br>
<br>
One trick worth noting:
the authors put a dummy activity in the
first position of the list, so that there
is no special first call of the function.
<br>
There is a <b>design pattern</b> here: oftentimes, it is
better to modify a data structure than to do
special coding for end cases.
</p>
<p>
<code>
<pre>
Recursive-Activity-Selector(s, f, k, n)
m = k + 1
while m ≤ n and s[m] < f[k]
m = m + 1
if m ≤ n
// + here is set union!
return a[m] + Recursive-Activity-Selector(s, f, m, n)
else
return NIL
</pre>
</code>
</p>
</details>
<details>
<summary class="sum2">
An iterative greedy algorithm
</summary>
<p>
As usual, it is fairly simple to transform the recursive
algorithm into an iterative version. The authors discuss tail
recursion in this section: let's review what this is.
</p>
<p>
<code>
<pre>
Greedy-Activity-Selector(s, f)
n = s.length
A = {a[1]}
k = 1
for m = 2 to n
if s[m] > f[k]
A = A + {a[m]} // + is set union!
k = m
return A
</pre>
</code>
</p>
</details>
<details>
<summary class="sum2">
Run the python code for greedy activity selector
</summary>
<p>
In the console below, type or paste:
<br/>
<code>
!git clone https://gist.github.com/bb22ea72d8b15fa965d2f50e6798ae50.git
<br/>
cd bb22ea72d8b15fa965d2f50e6798ae50
<br/>
from greedy_algorithms import *
<br/>
print("start: ", start, "\nfinish: ", finish)
<br/>
greedy_activity_selector(start, finish)
<br/>
</code>
</p>
<div class="python-console">
<iframe style="width: 640; height: 480;"
name="embedded_python_anywhere"
src="https://www.pythonanywhere.com/embedded3/" scrolling="yes">
</iframe>
<figcaption>
Python console
</figcaption>
</div>
</details>
</details>
<details>
<summary class="sum1">
Elements of the greedy strategy
</summary>
<p>
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Greedy_algorithm_36_cents.svg/280px-Greedy_algorithm_36_cents.svg.png">
</p>
<ol>
<li>Determine the optimal substructure of the problem.
</li>
<li>Develop a recursive solution.
</li>
<li>Show if we make the greedy choice, that only one
sub-problem remains.
</li>
<li>Prove that it is always safe to make the greedy
choice.
</li>
<li>Develop a recursive algorithm that implements the
greedy strategy.
</li>
<li>Convert the recursive algorithm to an iterative algorithm
</li>
</ol>
<details>
<summary class="sum2">
Greedy-choice property
</summary>
<p>
<img
src="https://upload.wikimedia.org/wikipedia/commons/8/8c/Greedy-search-path-example.gif">
<br>
<br>
For a greedy algorithm to work, the optimal choice must not
depend upon any sub-problems or any future choices.
<br>
<br>
To prove that a greedy choice will be appropriate for some
problem, we typically examine an optimal solution, and then
show that substituting in a greedy choice will also yield an
optimal solution.
</p>
</details>
<details>
<summary class="sum2">
Optimal substructure
</summary>
<p>
This is simpler then for dynamic programming
problems:
all we need to do is show that a
greedy choice combined with
an optimal solution to the sub problem of the rest of
the data gives us an optimal solution to the
original problem.
We use induction to show that making the
greedy choice at every
step produces an optimal solution.
</p>
</details>
<details>
<summary class="sum2">
Greedy versus dynamic programming
</summary>
<p>
Two knapsack problems:
</p>
<ol>
<li>A thief can take entire items from a store or not, and
put them in his knapsack.
</li>
<li>A thief can take whatever fraction of an item he wants,
and put it in his knapsack.
</li>
</ol>
<p>
The latter can be solved with a greedy algorithm, the former
cannot.
</p>
</details>
</details>
<details>
<summary class="sum1">
Huffman codes
</summary>
<p>
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Huffman_tree_2.svg/220px-Huffman_tree_2.svg.png">
<br>
<br>
Hoffman coding is away of compressing data that consists of
characters buy creating short binary representations for the
characters that occur most frequently in the data, and using longer
representations for characters that occur less frequently.
</p>
<figure>
<iframe width="560" height="315"
src="https://www.youtube.com/embed/dM6us854Jk0"
frameborder="0" allowfullscreen></iframe>
<figcaption>
Huffman coding
</figcaption>
</figure>
<details>
<summary class="sum2">
Prefix codes
</summary>
<p>
Prefix codes are coding schemes in which no codeword
is a prefix of a different codeword.
<br>
This makes decoding easier -- no lookahead.
(<b>else</b> and <b>else-if</b>)
<br />
It means that we never hit two letters on the same path
down the tree!
</p>
<table>
<tr>
<td>
</td>
<th>
a
</th>
<th>
b
</th>
<th>
c
</th>
<th>
d
</th>
<th>
e
</th>
<th>
f
</th>
</tr>
<tr>
<th>
Frequency (in 1000s)
</th>
<td>
45
</td>
<td>
13
</td>
<td>
12
</td>
<td>
16
</td>
<td>
9
</td>
<td>
5
</td>
</tr>
<tr>
<th>
Codeword
</th>
<td>
0
</td>
<td>
101
</td>
<td>
100
</td>
<td>
111
</td>
<td>
1101
</td>
<td>
1100
</td>
</tr>
</table>
</details>
<details>
<summary class="sum2">
Constructing a Huffman code
</summary>
<p>
We build a binary tree from the bottom-up, starting with the
two least-frequent characters, and building up from there. This
ensures the least-frequent characters have the longest codes.
<br>
<br>
Consider the phrase "Mississippi River".
This is 136 bits in 8-bit ASCII encoding.
<br>
<br>
Here is the Huffman coding for it:
<br>
<img src="graphics/Huffman.png">
<br>
<br>
I = 00
<br>
S = 01
<br>
P = 100
<br>
R - 101
<br>
M = 1100
<br>
V = 1101
<br>
E = 1110
<br>
_ = 1111
<br>
<br>
The final string:
<br>
110000010100010100100100001111101001101101
<br>
<br>
Try parsing it, and convince yourself that there is
only one possible interpretation of it. That is what
the prefix coding buys us.
</p>
</details>
<details>
<summary class="sum2">
Correctness of Huffman's algorithm
</summary>
<p>
We begin operating on an alphabet Σ. At each step,
we create a new alphabet, Σ', with two symbols of
Σ replaced by a new "meta-symbol".
<br>
<br>
<b>Base case</b>: For an alphabet of two symbols, the
algorithm outputs 0 for one of them, and 1 for the
other. And that is clearly optimal! (An alphabet of
size 1 is a non-problem!)
<br>
<br>
<b>Inductive step</b>: Assume the algorithm is correct
for input of size <i>n</i> - 1.
<br>
At each step in the algorithm, we replace the two least
frequent remaining symbols <i>a</i> and <i>b</i> with a
new symbol <i>ab</i>, whose probability is the sum of
the probabilities of <i>a</i> and <i>b</i>.
<br>
We always want the lowest frequency symbols to have the
longest encoding length.
<br>
Any choice among symbols at the lowest frequency will
be fine, since they all have equally low frequency. So
we can pair any of those lowest frequency symbols as we
wish.
<br>
Now assume that there is an encoding Σ'' that is
derived from Σ (like Σ') but differs in
choosing to combine <i>x</i> and <i>y</i> into a
<i>xy</i>. But since we made the greedy choice,
<i>xy</i> can be at best tied with <i>ab</i> meaning
Σ'' is at best another optimal encoding, and our
encoding Σ' is optimal after all.
</p>
</details>
</details>
<details>
<summary class="sum1">
Matroids and greedy methods
</summary>
<p>
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Vamos_matroid.svg/220px-Vamos_matroid.svg.png">
</p>
<details>
<summary class="sum2">
Matroids
</summary>
<h4>
A graph
</h4>
<p>
Consider the following graph, where the edges represent
roads and the vertices towns:
<br>
<br>
<img src="graphics/MatroidGraph.png">
<br>
<br>
If we want to build a set of roads that are only built
if there is no other route between towns, what sets are
possible?
<br>
</p>
<ul>
<li>∅
</li>
<li>{a} {b} {c} {d} {e}
</li>
<li>{a, b} {a, c} {a, d} {a, e} {b, c} {b, d} {b, e}
{c, d} {c, e}
</li>
<li>{a, b, c} {a, b, d}, {a, b, e} {a, c, d} {a, c, e}
</li>
</ul>
<p>
Notice:
</p>
<ul>
<li>f is useless!
</li>
<li>a is in every maximal set.
</li>
<li>d and e are never in the same set.
</li>
<li>b, c and d are never in the same set.
</li>
<li>b, c and e are never in the same set.
</li>
</ul>
<h4>
A vector space
</h4>
<p>
Now look at the following vector space in
ℝ<sup>3</sup>:
<br>
<br>
<img src="graphics/MatroidVectors.png">
<br>
(f is the vector 0, 0, 0.)
<br>
<br>
What sets of linearly independent vectors are possible?
</p>
<ul>
<li>∅
</li>
<li>{a} {b} {c} {d} {e}
</li>
<li>{a, b} {a, c} {a, d} {a, e} {b, c} {b, d} {b, e}
{c, d} {c, e}
</li>
<li>{a, b, c} {a, b, d}, {a, b, e} {a, c, d} {a, c, e}
</li>
</ul>
<p>
Notice:
</p>
<ul>
<li>f is useless!
</li>
<li>a is in every maximal set.
</li>
<li>d and e are never in the same set.
</li>
<li>b, c and d are never in the same set.
</li>
<li>b, c and e are never in the same set.
</li>
</ul>
<h4>
A matching problem
</h4>
<p>
You live in a small town with 3 women and 5 men who are
single but might be married off. There is a town
matchmaker who makes money by arranging marriages, and
so he wants to arrange as many as possible.
<br>
In this town, it's "ladies' choice," and the women are
numbered 1-3, and the men are a-f.
<br>
<br>
<img src="graphics/MatroidMatching.png">
<br>
<br>
What sets of matches are possible?
</p>
<ul>
<li>∅
</li>
<li>{a} {b} {c} {d} {e}
</li>
<li>{a, b} {a, c} {a, d} {a, e} {b, c} {b, d} {b, e}
{c, d} {c, e}
</li>
<li>{a, b, c} {a, b, d}, {a, b, e} {a, c, d} {a, c, e}
</li>
</ul>
<p>
Notice:
</p>
<ul>
<li>f is useless!
</li>
<li>a is in every maximal set.
</li>
<li>d and e are never in the same set.
</li>
<li>b, c and d are never in the same set.
</li>
<li>b, c and e are never in the same set.
</li>
</ul>
<h4>
The definition of a matroid
</h4>
<p>
We are looking at general
conditions for <i>independence</i>
of choices. All three situations turn out to be
surprisingly similar. They can all
be modeled using <i>matroids</i>.
<br>
<br>
We have a matroid when the following independence
conditions are satisfied:
</p>
<ol>
<li>∅ is independent.
</li>
<li>If set J is independent and I is a subset of J,
then I is independent.
</li>
<li>If I and J are independent, and cardinality(I) <
cardinality(J), then there is some <i>j</i> in J
and not in I, so that I ∪ <i>j</i> is also
independent.
</li>
</ol>
<p>
A matroid consists of (S, I), where S is a set, and I
is a set of subsets of S, for which axioms 1-3
above are satisfied.
<br>
<br>
All three situations described above, the vector space,
the graph, and the matching problem, turn out to be the
<i>same</i> matroid.
(Technically, they are <i>isomorphic</i> matroids.)
</p>
<h4>
The bases of a matroid
</h4>
<p>
A subset in I is a <i>basis</i> for a
matroid if it is a <i>maximal</i>
subset, which here means it is not contained in any
larger subset that is in I.
<br>
<br>
So in the above examples, the bases are:
<br>
{a, b, c} {a, b, d}, {a, b, e} {a, c, d} {a, c, e}
<br>
<br>
<b>Theorem</b>:
Every basis of a matroid is of the same size.
<br>
<b>Proof</b>: Let assume that there are some bases
A and B of a matroid such that |B| < |A|.
<br>
Then by the exchange axiom (#3 above),
there is some
element <i>a</i> of A that can be moved
into B, and B
will still be independent.
<br>
Therefore, it was <i>not</i>
a maximal independent subset after
all!
<br>
<br>
Translation into the different matroid realms:
<br>
<br>
The dimension of a vector space is the
size of any of its bases.
<br>
<br>
Every spanning tree has the same number of edges.
<br>
<br>
We are proving things about vector spaces and graphs
simply by examining the axioms of matroids!
</p>
<h4>
Credit
</h4>
<p>
This section draws on lectures by Federico Ardila:
<a href="https://www.youtube.com/watch?v=4EvpzV_3RXI">
here
</a>
and
<a
href="https://www.youtube.com/watch?v=pe5MaEugAwg&list=PL-XzhVrXIVeSu_b29hbX5xJ0bRThokU8a">
here</a>.
</p>
</details>
<details>
<summary class="sum2">
Greedy algorithms on a weighted matroid
</summary>