1 00:00:01,140 --> 00:00:06,240 So we saw in the last video why if you represent scheduling 2 00:00:06,240 --> 00:00:08,580 constraints among courses by a digraph 3 00:00:08,580 --> 00:00:11,900 that it's critical that that digraph in fact be a DAG. 4 00:00:11,900 --> 00:00:15,810 And let's now look at this scheduling issue represented 5 00:00:15,810 --> 00:00:17,700 by DAGs in more detail. 6 00:00:17,700 --> 00:00:23,670 So here's a chart of a selection of Course 6 prerequisites-- 7 00:00:23,670 --> 00:00:26,610 some of them obsolete, but they serve the purposes 8 00:00:26,610 --> 00:00:28,790 of being an illustrative example-- 9 00:00:28,790 --> 00:00:30,630 and the little arrows here are indicating 10 00:00:30,630 --> 00:00:31,780 arrows in the digraph. 11 00:00:31,780 --> 00:00:34,490 So what this tells me is that 18.01 12 00:00:34,490 --> 00:00:37,150 is listed as an immediate prerequisite 13 00:00:37,150 --> 00:00:40,180 in the catalog for 6.042. 14 00:00:40,180 --> 00:00:45,940 18.01 is also an immediate prerequisite of 18.02. 15 00:00:45,940 --> 00:00:52,890 6.001 and 6.004 are both prerequisites of 6.033, 16 00:00:52,890 --> 00:00:58,200 and 6.042 of 6.046, and 6.046 of 6.840. 17 00:00:58,200 --> 00:01:01,560 So we're seeing here this indirect prerequisite issue 18 00:01:01,560 --> 00:01:05,050 that I mentioned before, which is that even though the only 19 00:01:05,050 --> 00:01:08,790 thing listed as a prerequisite for 6.840 in the catalog is 20 00:01:08,790 --> 00:01:12,850 6.046, as a matter of fact in order to take 6.046 you have 21 00:01:12,850 --> 00:01:14,720 to have taken 6.042. 22 00:01:14,720 --> 00:01:20,020 So 6.042 is an indirect prerequisite of 6.840. 23 00:01:20,020 --> 00:01:24,120 So in terms of graph language and path language, 24 00:01:24,120 --> 00:01:27,470 a subject u is an indirect prerequisite of v 25 00:01:27,470 --> 00:01:28,880 when there's is a positive length 26 00:01:28,880 --> 00:01:31,930 path from u to v in the digraph that 27 00:01:31,930 --> 00:01:35,950 describes the prerequisite structure among the classes. 28 00:01:35,950 --> 00:01:39,270 It simply means that-- using our notation for R plus 29 00:01:39,270 --> 00:01:41,460 is the positive length path relation 30 00:01:41,460 --> 00:01:44,150 of a digraph or a binary relation R-- 31 00:01:44,150 --> 00:01:47,470 it simply means u R plus v, which 32 00:01:47,470 --> 00:01:52,880 is read as there is a positive length path from u to v. 33 00:01:52,880 --> 00:01:56,020 Now, a key idea that we're going to be examining 34 00:01:56,020 --> 00:01:58,490 in learning how to do scheduling is 35 00:01:58,490 --> 00:02:00,500 the idea of a minimal subject. 36 00:02:00,500 --> 00:02:02,730 So the definition of a minimal subject 37 00:02:02,730 --> 00:02:05,060 is a subject that has no prerequisites, 38 00:02:05,060 --> 00:02:08,229 no arrows in, a freshman subject. 39 00:02:08,229 --> 00:02:09,400 So nothing comes in. 40 00:02:09,400 --> 00:02:12,150 There are three examples of subjects 41 00:02:12,150 --> 00:02:15,380 with no prerequisites in the preceding chart, 42 00:02:15,380 --> 00:02:18,790 namely 18.01, 8.02, and 6.001. 43 00:02:18,790 --> 00:02:21,380 Let me say a word about where this funny terminology minimal 44 00:02:21,380 --> 00:02:22,900 comes from. 45 00:02:22,900 --> 00:02:26,150 It's because another way to talk about DAGs 46 00:02:26,150 --> 00:02:29,690 is in terms of things that are like order relations called 47 00:02:29,690 --> 00:02:33,520 partial orders, which we'll be looking at shortly. 48 00:02:33,520 --> 00:02:38,870 And so you think of the later subjects 49 00:02:38,870 --> 00:02:42,340 as being bigger than the earlier subjects. 50 00:02:42,340 --> 00:02:44,800 So a minimal subject is one where 51 00:02:44,800 --> 00:02:47,620 there is nothing less than it. 52 00:02:47,620 --> 00:02:49,727 Now, there might be several minimal subjects, 53 00:02:49,727 --> 00:02:51,560 because it might be that neither one of them 54 00:02:51,560 --> 00:02:53,351 is less than the other, but there's nothing 55 00:02:53,351 --> 00:02:54,900 less than 18.01. 56 00:02:54,900 --> 00:02:59,010 There's no other subject that you have to take before 18.01. 57 00:02:59,010 --> 00:03:02,250 So that's the definition of minimal. 58 00:03:02,250 --> 00:03:03,600 Nothing smaller. 59 00:03:03,600 --> 00:03:05,350 Now, you could ask what's a minimum, which 60 00:03:05,350 --> 00:03:07,250 you may be more familiar with. 61 00:03:07,250 --> 00:03:11,020 A minimum means that not only is there nothing before it, 62 00:03:11,020 --> 00:03:13,220 but it comes before everything else. 63 00:03:13,220 --> 00:03:16,790 It would be the earliest of all possible subjects 64 00:03:16,790 --> 00:03:18,710 in the indirect prerequisite chain. 65 00:03:18,710 --> 00:03:20,890 There isn't any in this example, but there actually 66 00:03:20,890 --> 00:03:22,970 used to be one at MIT. 67 00:03:22,970 --> 00:03:25,980 For a while, we experimented with giving an orientation week 68 00:03:25,980 --> 00:03:29,190 summer assignment, that is, an assignment over the summer 69 00:03:29,190 --> 00:03:31,730 for newly admitted students in order for them 70 00:03:31,730 --> 00:03:34,340 to take a subject during orientation 71 00:03:34,340 --> 00:03:37,250 week in which they discussed some book that they had all 72 00:03:37,250 --> 00:03:39,240 been assigned to read beforehand. 73 00:03:39,240 --> 00:03:41,880 Seemed like a great idea to kind of pull the freshman community 74 00:03:41,880 --> 00:03:44,710 together, but it turned out to be unsustainable 75 00:03:44,710 --> 00:03:47,180 because they couldn't find enough faculty 76 00:03:47,180 --> 00:03:50,380 and others willing to conduct these seminars. 77 00:03:50,380 --> 00:03:53,703 So MIT stopped having a minimum subject. 78 00:03:56,094 --> 00:03:57,510 So let's look at the prerequisites 79 00:03:57,510 --> 00:04:00,292 again, and discuss how to do a scheduling. 80 00:04:00,292 --> 00:04:02,500 And the first thing we're going to do in the schedule 81 00:04:02,500 --> 00:04:04,820 is, as I say, identify the minimal elements. 82 00:04:04,820 --> 00:04:07,650 There are the three of them that we mentioned. 83 00:04:07,650 --> 00:04:11,840 And we're going to start by deciding that we'll take 84 00:04:11,840 --> 00:04:14,070 those three in the first term. 85 00:04:14,070 --> 00:04:16,570 So we're going to be operating with basically what's 86 00:04:16,570 --> 00:04:17,784 called a greedy strategy. 87 00:04:17,784 --> 00:04:19,200 We're going to take as many things 88 00:04:19,200 --> 00:04:23,414 as we possibly can take at any term given the constraints. 89 00:04:23,414 --> 00:04:25,830 So we can take all the freshman subjects in our first term 90 00:04:25,830 --> 00:04:27,740 because they have no prerequisites. 91 00:04:27,740 --> 00:04:30,040 Well, the next step, then, is just get rid of them 92 00:04:30,040 --> 00:04:31,570 because they're scheduled already. 93 00:04:31,570 --> 00:04:35,380 So we can get rid of all those occurrences of 18.01, 8.02, 94 00:04:35,380 --> 00:04:40,420 and 6.001, not only-- there are other occurrences as well here 95 00:04:40,420 --> 00:04:43,280 where 18.01 is a prerequisite for things. 96 00:04:43,280 --> 00:04:46,080 So they're all gone, and we get a simplified diagram 97 00:04:46,080 --> 00:04:48,760 where we've removed the minimal elements. 98 00:04:48,760 --> 00:04:51,710 Now in the new diagram, there are now 99 00:04:51,710 --> 00:04:53,560 things that didn't used to be minimal 100 00:04:53,560 --> 00:04:55,200 before but are minimal now. 101 00:04:55,200 --> 00:04:56,760 These are the new minimal elements, 102 00:04:56,760 --> 00:04:58,490 and we can identify those. 103 00:04:58,490 --> 00:05:01,480 Here are five subjects-- four here and one there-- 104 00:05:01,480 --> 00:05:03,790 that now have no more prerequisites. 105 00:05:03,790 --> 00:05:06,770 These are kind of the second level minimal elements, 106 00:05:06,770 --> 00:05:09,670 and we're going to schedule them next. 107 00:05:09,670 --> 00:05:12,210 So those are all the subjects that we can possibly 108 00:05:12,210 --> 00:05:16,660 take after we've taken the first set of minimal subjects. 109 00:05:16,660 --> 00:05:18,160 They're the second level minimals. 110 00:05:18,160 --> 00:05:19,930 And we'll schedule them in the next term. 111 00:05:19,930 --> 00:05:25,140 This is our five subject second term schedule. 112 00:05:25,140 --> 00:05:27,760 Likewise, you delete these guys, and then you 113 00:05:27,760 --> 00:05:31,660 discover that 6.046 and 6.004 are the resulting minimal ones, 114 00:05:31,660 --> 00:05:34,620 which it's now possible to take because all their prerequisites 115 00:05:34,620 --> 00:05:35,740 have been satisfied. 116 00:05:35,740 --> 00:05:39,450 So we schedule them in the third term, 6.840 and 6.033, 117 00:05:39,450 --> 00:05:41,650 by the same reasoning, in the fourth term, 118 00:05:41,650 --> 00:05:44,180 and 6.857 in the fifth term. 119 00:05:44,180 --> 00:05:48,050 There is our complete term schedule obtained 120 00:05:48,050 --> 00:05:49,460 in this particular way. 121 00:05:49,460 --> 00:05:51,584 There's, of course, many other ways to schedule it, 122 00:05:51,584 --> 00:05:54,700 but this is a particular orderly way where the strategy, again, 123 00:05:54,700 --> 00:05:55,260 is greedy. 124 00:05:55,260 --> 00:05:56,980 You take as many things as you possibly 125 00:05:56,980 --> 00:05:59,616 can take in a given term. 126 00:05:59,616 --> 00:06:00,990 Now, there are some concepts that 127 00:06:00,990 --> 00:06:02,781 come up when you're talking about schedules 128 00:06:02,781 --> 00:06:04,880 that are worth introducing. 129 00:06:04,880 --> 00:06:06,940 So one of them is an antichain. 130 00:06:06,940 --> 00:06:10,000 An antichain is-- in this particular example 131 00:06:10,000 --> 00:06:12,060 means a set of subjects where there 132 00:06:12,060 --> 00:06:15,080 are no indirect prerequisites among them. 133 00:06:15,080 --> 00:06:19,320 They can be taken in any order, because it doesn't matter 134 00:06:19,320 --> 00:06:22,820 whether you've taken one or not when you're thinking 135 00:06:22,820 --> 00:06:24,660 about taking the others. 136 00:06:24,660 --> 00:06:28,230 In technical language, again motivated 137 00:06:28,230 --> 00:06:31,860 by the idea of thinking of there being a path 138 00:06:31,860 --> 00:06:34,270 as though it was less than or equal to something, 139 00:06:34,270 --> 00:06:36,170 these are elements that are incomparable. 140 00:06:36,170 --> 00:06:38,680 Neither one is less than or equal to another. 141 00:06:38,680 --> 00:06:41,730 So in terms of the path relation, 142 00:06:41,730 --> 00:06:44,670 u is incomparable to v if and only 143 00:06:44,670 --> 00:06:47,740 if there is no path from u to v of positive length and there's 144 00:06:47,740 --> 00:06:51,030 no positive length path from v to u. 145 00:06:51,030 --> 00:06:53,180 So let's look at some antichains-- and the part 146 00:06:53,180 --> 00:06:54,750 of the point of defining it is we 147 00:06:54,750 --> 00:06:59,500 have chosen antichains as our schedule for each term. 148 00:06:59,500 --> 00:07:02,060 So the freshman subjects with no prerequisites, 149 00:07:02,060 --> 00:07:04,420 clearly there's no path among them, 150 00:07:04,420 --> 00:07:06,090 because there is no path to them at all. 151 00:07:06,090 --> 00:07:08,160 So they are an antichain. 152 00:07:08,160 --> 00:07:11,400 The next level we chose were the second level 153 00:07:11,400 --> 00:07:15,870 minimal elements, which only had as prerequisites 154 00:07:15,870 --> 00:07:19,500 the original minimal elements, and so certainly none of them 155 00:07:19,500 --> 00:07:22,390 was a prerequisite of the others. 156 00:07:22,390 --> 00:07:26,777 So that's another example of an antichain. 157 00:07:26,777 --> 00:07:28,860 And of course the third level and the fourth level 158 00:07:28,860 --> 00:07:30,318 and the fifth level are antichains. 159 00:07:30,318 --> 00:07:34,090 But not all antichains are there in our schedule. 160 00:07:34,090 --> 00:07:38,060 So for example here, is a diagonal lying antichain. 161 00:07:38,060 --> 00:07:42,720 6.840, 6.004, and 6.034 have no paths between them. 162 00:07:42,720 --> 00:07:46,290 So in fact it's possible to take them simultaneously, 163 00:07:46,290 --> 00:07:48,550 because you could have taken all their prerequisites 164 00:07:48,550 --> 00:07:51,110 in the upper left here and then take the three of them. 165 00:07:51,110 --> 00:07:54,200 So that's what an antichain means here. 166 00:07:54,200 --> 00:07:57,700 So the technical definition is no path between any two 167 00:07:57,700 --> 00:08:01,160 of them, but in terms of the scheduling of courses, 168 00:08:01,160 --> 00:08:04,930 it means it's possible to take them in the same term 169 00:08:04,930 --> 00:08:06,960 if you've satisfied all their prerequisites, 170 00:08:06,960 --> 00:08:10,220 which it is possible to do. 171 00:08:10,220 --> 00:08:15,860 So let's ask about the various patterns of scheduling 172 00:08:15,860 --> 00:08:16,890 that are possible. 173 00:08:16,890 --> 00:08:20,160 We've discovered this particular greedy one, 174 00:08:20,160 --> 00:08:22,630 where we take as many things as we can each term. 175 00:08:22,630 --> 00:08:24,950 But suppose that I was constrained to only take 176 00:08:24,950 --> 00:08:26,050 one subject per term. 177 00:08:26,050 --> 00:08:28,390 I was going to-- I have an outside job, 178 00:08:28,390 --> 00:08:30,430 I'm too busy to take more than one class a term, 179 00:08:30,430 --> 00:08:32,990 and if MIT will let me dawdle so long, 180 00:08:32,990 --> 00:08:34,450 that's what I'd like to do. 181 00:08:34,450 --> 00:08:35,409 So can I do this? 182 00:08:35,409 --> 00:08:36,150 Yeah, well sure. 183 00:08:36,150 --> 00:08:39,480 Just schedule all the minimal elements first 184 00:08:39,480 --> 00:08:40,950 in any order, one, two, three. 185 00:08:40,950 --> 00:08:43,770 And then schedule the five second level minimal elements 186 00:08:43,770 --> 00:08:46,150 next, and the third level, and so on. 187 00:08:46,150 --> 00:08:47,860 And it's perfectly possible, then, 188 00:08:47,860 --> 00:08:50,830 to modify the schedule that we found 189 00:08:50,830 --> 00:08:54,610 into a schedule in which you only take one subject per term, 190 00:08:54,610 --> 00:08:56,990 and of course you only take a subject 191 00:08:56,990 --> 00:09:00,400 after you've taken all of its indirect 192 00:09:00,400 --> 00:09:02,270 and direct prerequisites. 193 00:09:02,270 --> 00:09:04,830 This is called a topological sort. 194 00:09:04,830 --> 00:09:08,020 Again, the sorting word comes from the motivation 195 00:09:08,020 --> 00:09:11,170 of thinking of there being a path as like a less 196 00:09:11,170 --> 00:09:12,640 than or equal to relation. 197 00:09:12,640 --> 00:09:16,630 So we're sorting things in order of increasing size. 198 00:09:16,630 --> 00:09:20,200 18.01 would be, in this case, a smallest element 199 00:09:20,200 --> 00:09:25,640 and 6.857 a biggest in this list of elements. 200 00:09:25,640 --> 00:09:28,750 A chain is kind of technically, literally, 201 00:09:28,750 --> 00:09:31,420 a thing called the dual of an antichain. 202 00:09:31,420 --> 00:09:33,480 A chain is a sequence of subjects 203 00:09:33,480 --> 00:09:36,350 that must be taken in order. 204 00:09:36,350 --> 00:09:38,960 That is, these are subjects where for any two of them, 205 00:09:38,960 --> 00:09:41,030 you know which one has to come first. 206 00:09:41,030 --> 00:09:43,110 That is, between any two of them there is 207 00:09:43,110 --> 00:09:45,070 a path in one way or the other. 208 00:09:45,070 --> 00:09:46,810 Now of course, it's a DAG, so there can't 209 00:09:46,810 --> 00:09:48,480 be paths in both directions. 210 00:09:48,480 --> 00:09:52,690 So a chain is simply a set of comparable elements, which 211 00:09:52,690 --> 00:09:55,800 implies that there's an order in which they have to be taken. 212 00:09:55,800 --> 00:09:58,550 So here are some chains. 213 00:09:58,550 --> 00:10:01,160 This one was shown pictorially as a vertical chain 214 00:10:01,160 --> 00:10:03,860 with five courses in it. 215 00:10:03,860 --> 00:10:05,370 Here's a vertical chain of four. 216 00:10:05,370 --> 00:10:07,260 And not all of them are vertical. 217 00:10:07,260 --> 00:10:10,800 Here's a chain where you have to take 18.01 before you take 218 00:10:10,800 --> 00:10:13,810 18.03 before you take 6.004. 219 00:10:13,810 --> 00:10:16,830 So they form a chain. 220 00:10:16,830 --> 00:10:18,530 It's important to realize that this 221 00:10:18,530 --> 00:10:20,190 is a chain with five subjects in it, 222 00:10:20,190 --> 00:10:24,780 but a chain doesn't have to have every possible element that 223 00:10:24,780 --> 00:10:25,530 could be in it. 224 00:10:25,530 --> 00:10:28,620 It's still a chain even if it's only got these three subjects, 225 00:10:28,620 --> 00:10:31,580 because there's a path from 8.02 to 6.004 226 00:10:31,580 --> 00:10:36,060 and a path from 6.004 to 6.857. 227 00:10:36,060 --> 00:10:38,410 But maximum length chains, chains 228 00:10:38,410 --> 00:10:42,700 that are as full as possible, are important theoretically. 229 00:10:42,700 --> 00:10:46,710 And so this in particular is a maximal length chain. 230 00:10:46,710 --> 00:10:50,320 The longest chain here is of length 5. 231 00:10:50,320 --> 00:10:51,490 Now, it's not the only one. 232 00:10:51,490 --> 00:10:54,350 There's another chain of length 5 here if you look for it. 233 00:10:54,350 --> 00:10:57,620 But no chain is of length longer than 5 234 00:10:57,620 --> 00:11:00,700 and there is one of length 5, and that leads us 235 00:11:00,700 --> 00:11:04,710 to the question of how many terms is it necessarily 236 00:11:04,710 --> 00:11:06,280 going to take to graduate. 237 00:11:06,280 --> 00:11:11,970 Well, we saw that you can graduate in five. 238 00:11:11,970 --> 00:11:16,720 But given that there's a maximum chain of length 5, 239 00:11:16,720 --> 00:11:18,940 it means that you can't do it in fewer, 240 00:11:18,940 --> 00:11:24,860 because those five courses have to be taken consecutively. 241 00:11:24,860 --> 00:11:26,650 The third has to be taken in a term 242 00:11:26,650 --> 00:11:28,440 after the first two have been taken. 243 00:11:28,440 --> 00:11:30,470 The second has to be taken after the first. 244 00:11:30,470 --> 00:11:33,180 If you have a chain of any size, actually, the number 245 00:11:33,180 --> 00:11:36,430 of terms to graduate has to be at least as big 246 00:11:36,430 --> 00:11:38,180 as that chain, which means it has 247 00:11:38,180 --> 00:11:41,750 to be at least as many terms as a maximum size chain. 248 00:11:41,750 --> 00:11:43,640 So five terms are necessary, and we 249 00:11:43,640 --> 00:11:46,330 saw using our minimal strategy of being 250 00:11:46,330 --> 00:11:50,780 greedy that you can always do it in maximum chain length. 251 00:11:50,780 --> 00:11:52,960 So five are also sufficient. 252 00:11:52,960 --> 00:11:56,010 This is providing that you can take an unlimited number 253 00:11:56,010 --> 00:11:57,010 of subjects per term. 254 00:11:57,010 --> 00:12:00,100 Remember our strategy to graduate in five terms 255 00:12:00,100 --> 00:12:03,390 was to take as many subjects as we possibly could each term. 256 00:12:03,390 --> 00:12:06,920 So there's the sufficient way to take subjects 257 00:12:06,920 --> 00:12:08,810 to graduate in five terms. 258 00:12:08,810 --> 00:12:10,720 And of course, one consequence is 259 00:12:10,720 --> 00:12:13,210 that in my second term freshman year, 260 00:12:13,210 --> 00:12:16,100 I was taking five subjects because it was possible. 261 00:12:16,100 --> 00:12:18,750 But that leaves me with a kind of heavily loaded term 262 00:12:18,750 --> 00:12:21,010 compared to-- here's a term with two subjects, 263 00:12:21,010 --> 00:12:24,770 and there's a term with only one subject at the very end. 264 00:12:24,770 --> 00:12:28,730 So it's possible, in fact, to somewhat adjust the term load. 265 00:12:28,730 --> 00:12:34,460 Let's just shift taking 18.02 to the third term. 266 00:12:34,460 --> 00:12:36,380 It's perfectly feasible to do that, 267 00:12:36,380 --> 00:12:40,560 because I will have satisfied all the prerequisites of 18.02 268 00:12:40,560 --> 00:12:42,190 after the first term, but I don't have 269 00:12:42,190 --> 00:12:43,560 to take it in the second term. 270 00:12:43,560 --> 00:12:44,820 Let's shift it off. 271 00:12:44,820 --> 00:12:47,390 So now I've lightened the load in the second term 272 00:12:47,390 --> 00:12:49,340 to four subjects, somewhat increasing 273 00:12:49,340 --> 00:12:52,070 the load-- I had to do it somewhere-- in the third term 274 00:12:52,070 --> 00:12:53,480 to three subjects. 275 00:12:53,480 --> 00:12:57,440 So now I have to take no more than four subjects a term. 276 00:12:57,440 --> 00:12:59,620 And as a matter of fact, if you fiddle, 277 00:12:59,620 --> 00:13:03,130 you can actually find a graduating schedule 278 00:13:03,130 --> 00:13:08,650 in which you can only take three subjects per term. 279 00:13:08,650 --> 00:13:13,270 And we will examine what's the minimum number of subjects 280 00:13:13,270 --> 00:13:15,873 per term in the next segment.