CS50-raw / jUyQqLvg8Qw.json
cutehusky's picture
Upload folder using huggingface_hub
0791e78 verified
[
{
"text": "[MUSIC PLAYING]",
"start": 0.499,
"duration": 3.704
},
{
"text": "SPEAKER 1: All right.",
"start": 15.844,
"duration": 0.956
},
{
"text": "So this is CS50.",
"start": 16.8,
"duration": 1.8
},
{
"text": "And this is the start of week 3.",
"start": 18.6,
"duration": 1.81
},
{
"text": "And you'll recall that last time,\nwe introduced a number of new ideas",
"start": 20.41,
"duration": 3.23
},
{
"text": "that we'll now start taking for granted\nas being already under our belt.",
"start": 23.64,
"duration": 3.48
},
{
"text": "In particular, we looked last\ntime at debugging more generally.",
"start": 27.12,
"duration": 3.47
},
{
"text": "And recall that debugging is the\nprocess of removing bugs from your code,",
"start": 30.59,
"duration": 3.11
},
{
"text": "removing mistakes from your code.",
"start": 33.7,
"duration": 1.69
},
{
"text": "And we proposed these\nthree CS50-specific tools.",
"start": 35.39,
"duration": 3.34
},
{
"text": "In particular, help50, which\nis a command line tool.",
"start": 38.73,
"duration": 2.589
},
{
"text": "Something that you can\nrun at your keyboard",
"start": 41.319,
"duration": 1.791
},
{
"text": "and actually run it\nbefore your own command.",
"start": 43.11,
"duration": 2.22
},
{
"text": "So that if you don't\nunderstand some error",
"start": 45.33,
"duration": 1.75
},
{
"text": "message from a program you're\ncompiling or a command you're running,",
"start": 47.08,
"duration": 2.833
},
{
"text": "you can actually see some\nhelpful output from CS50 staff.",
"start": 49.913,
"duration": 3.297
},
{
"text": "eprintf, which, by contrast, is\nsomething you can put into your code,",
"start": 53.21,
"duration": 4.36
},
{
"text": "like printf, and print\na message to yourself.",
"start": 57.57,
"duration": 2.23
},
{
"text": "And nicely enough, it's going to\nactually include the line number",
"start": 59.8,
"duration": 2.758
},
{
"text": "and the file name from which it came.",
"start": 62.558,
"duration": 1.541
},
{
"text": "So you can identify where\nsome output is coming.",
"start": 64.099,
"duration": 2.171
},
{
"text": "And then lastly, debug 50 which is the\nmost sophisticated of these programs.",
"start": 66.27,
"duration": 3.75
},
{
"text": "And debug 50 when you run\nit at the command line,",
"start": 70.02,
"duration": 2.7
},
{
"text": "followed by the name of your\nprogram in the usual way,",
"start": 72.72,
"duration": 2.417
},
{
"text": "it's actually going to open\nup what's called a debugger.",
"start": 75.137,
"duration": 2.333
},
{
"text": "A graphical user interface\nthat CS50 staff put together",
"start": 77.47,
"duration": 3.517
},
{
"text": "that will actually let you\nstep through your code,",
"start": 80.987,
"duration": 2.083
},
{
"text": "see variables, and generally\nunderstand it better.",
"start": 83.07,
"duration": 3.52
},
{
"text": "So we also looked at this\nin the context of Ovaltine",
"start": 86.59,
"duration": 2.91
},
{
"text": "in particular, and Little Ralphy.",
"start": 89.5,
"duration": 1.39
},
{
"text": "And we looked at cryptography,\nthe art of concealing information.",
"start": 90.89,
"duration": 4.28
},
{
"text": "And indeed, among the\nchallenges in CS50,",
"start": 95.17,
"duration": 2.31
},
{
"text": "ultimately if you choose\nto accept them, are",
"start": 97.48,
"duration": 2.08
},
{
"text": "things like implementing\nCaesar cipher and Vigenere",
"start": 99.56,
"duration": 2.88
},
{
"text": "cipher, cracking passwords.",
"start": 102.44,
"duration": 2.04
},
{
"text": "So indeed, those problems lie ahead\nand draw inspiration from this domain.",
"start": 104.48,
"duration": 4.1
},
{
"text": "And then, we focused more\ntechnically on what a string is.",
"start": 108.58,
"duration": 3.31
},
{
"text": "So Zamyla, a name we keep taking for\ngranted, that a computer can express.",
"start": 111.89,
"duration": 3.58
},
{
"text": "Z-A-M-Y-L-A, as a string\nor a phrase in a program.",
"start": 115.47,
"duration": 5.16
},
{
"text": "But it turns out that\nunderneath the hood,",
"start": 120.63,
"duration": 2.83
},
{
"text": "strings are a little more mundane.",
"start": 123.46,
"duration": 2.0
},
{
"text": "They really are just\nthis grid of information.",
"start": 125.46,
"duration": 2.82
},
{
"text": "And we might draw Zamyla's\ncharacters boxed in like this.",
"start": 128.28,
"duration": 2.534
},
{
"text": "But if you think of what's\ninside of your computer itself,",
"start": 130.814,
"duration": 2.416
},
{
"text": "you have a whole bunch\nof memory, or RAM.",
"start": 133.23,
"duration": 2.24
},
{
"text": "And inside of that RAM,\nyou have Z-A-M-Y-L-A,",
"start": 135.47,
"duration": 3.95
},
{
"text": "but then this special character.",
"start": 139.42,
"duration": 1.57
},
{
"text": "What is this /0 used for.",
"start": 140.99,
"duration": 2.97
},
{
"text": "Why is there this seemingly strange\ncharacter at the end of Zamyla's name?",
"start": 143.96,
"duration": 5.1
},
{
"text": "Anyone?",
"start": 149.06,
"duration": 1.1
},
{
"text": "Yeah.",
"start": 150.16,
"duration": 0.944
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 151.104,
"duration": 0.916
},
{
"text": "SPEAKER 1: Yeah, to denote\nthe end of the string.",
"start": 152.02,
"duration": 1.75
},
{
"text": "Because after all, if we were to\nhave someone else's name here,",
"start": 153.77,
"duration": 2.624
},
{
"text": "if the next string I got\nis Maria, for instance.",
"start": 156.394,
"duration": 2.846
},
{
"text": "M-A-R-I-A, we need to be able\nto know where Zamyla's name ends",
"start": 159.24,
"duration": 5.1
},
{
"text": "and Maria's name starts in memory.",
"start": 164.34,
"duration": 1.59
},
{
"text": "Because at the end of the day,\nC, and programming in particular,",
"start": 165.93,
"duration": 3.42
},
{
"text": "isn't really all that sophisticated.",
"start": 169.35,
"duration": 1.5
},
{
"text": "At the end of the day, the only\nplace you have to store things",
"start": 170.85,
"duration": 2.583
},
{
"text": "is your computer's memory or RAM.",
"start": 173.433,
"duration": 1.537
},
{
"text": "And each of these boxes represents a\nbyte of memory inside of your computer.",
"start": 174.97,
"duration": 4.27
},
{
"text": "And so if all this is-- so\nfar as the computer cares--",
"start": 179.24,
"duration": 2.96
},
{
"text": "is a sequence of six\nalphabetical letters,",
"start": 182.2,
"duration": 2.44
},
{
"text": "the computer needs to be told\nor given a hint as with this /0,",
"start": 184.64,
"duration": 4.46
},
{
"text": "which just represents 8 zero bits, as to\nwhere Zamyla's name ends and something",
"start": 189.1,
"duration": 4.22
},
{
"text": "else begins.",
"start": 193.32,
"duration": 1.64
},
{
"text": "And we use this as an opportunity\nto introduce ultimately",
"start": 194.96,
"duration": 2.6
},
{
"text": "command line arguments.",
"start": 197.56,
"duration": 1.22
},
{
"text": "So in particular, we've been\nwriting programs thus far",
"start": 198.78,
"duration": 2.25
},
{
"text": "with just int main void.",
"start": 201.03,
"duration": 1.12
},
{
"text": "And void, we realized, signifies that\na program takes no command line inputs.",
"start": 202.15,
"duration": 5.21
},
{
"text": "It can still call functions, like get\nstring and get int and get [? flow. ?]",
"start": 207.36,
"duration": 3.74
},
{
"text": "But when you run the program, you can't\nput any additional words at the prompt",
"start": 211.1,
"duration": 3.57
},
{
"text": "after it if you've declared\nmain as taking void as input.",
"start": 214.67,
"duration": 3.64
},
{
"text": "Nothing as input.",
"start": 218.31,
"duration": 1.34
},
{
"text": "But we introduced instead\nthis, int main int arg",
"start": 219.65,
"duration": 3.01
},
{
"text": "c string arg v open bracket\nclose bracket, which",
"start": 222.66,
"duration": 3.0
},
{
"text": "means main can alternatively take two\ninputs from the so-called command line",
"start": 225.66,
"duration": 4.294
},
{
"text": "when you run it.",
"start": 229.954,
"duration": 0.666
},
{
"text": "It can take arg c and arg\nv. And what was arg c?",
"start": 230.62,
"duration": 4.91
},
{
"text": "What was arg c?",
"start": 235.53,
"duration": 2.86
},
{
"text": "Arg c.",
"start": 238.39,
"duration": 1.57
},
{
"text": "Yeah, argument.",
"start": 239.96,
"duration": 1.0
},
{
"text": "Yeah.",
"start": 240.96,
"duration": 0.94
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 241.9,
"duration": 0.94
},
{
"text": "SPEAKER 1: Yeah, the number\nof command line arguments.",
"start": 242.84,
"duration": 2.25
},
{
"text": "Arg c for argument count.",
"start": 245.09,
"duration": 1.55
},
{
"text": "So how many words did\nyou type at the prompt?",
"start": 246.64,
"duration": 2.19
},
{
"text": "And arg v means argument\nvector, which is",
"start": 248.83,
"duration": 2.69
},
{
"text": "another way of saying it's an\narray, a contiguous block of memory",
"start": 251.52,
"duration": 5.58
},
{
"text": "inside of which are all\nof the words themselves",
"start": 257.1,
"duration": 2.32
},
{
"text": "that you might have typed at the prompt.",
"start": 259.42,
"duration": 1.8
},
{
"text": "So this time, we're\ngoing to build on that.",
"start": 261.22,
"duration": 1.88
},
{
"text": "We're going to focus\ntoday mostly on ideas.",
"start": 263.1,
"duration": 3.1
},
{
"text": "Mostly on algorithms.",
"start": 266.2,
"duration": 1.08
},
{
"text": "Mostly on problem-solving and less\non the lower-level implementation",
"start": 267.28,
"duration": 2.86
},
{
"text": "details of code.",
"start": 270.14,
"duration": 0.85
},
{
"text": "Though, we'll look at\na couple of examples.",
"start": 270.99,
"duration": 1.81
},
{
"text": "So this more generally is\nwhat's called an array.",
"start": 272.8,
"duration": 2.64
},
{
"text": "If you think of your computer's\nmemory as just a block of memory,",
"start": 275.44,
"duration": 3.43
},
{
"text": "block of bytes.",
"start": 278.87,
"duration": 1.17
},
{
"text": "And maybe it's byte 0, then byte 1.",
"start": 280.04,
"duration": 1.98
},
{
"text": "Then, byte 2, just because you\ncan number them, certainly.",
"start": 282.02,
"duration": 2.64
},
{
"text": "If you think of them that way, this\nis kind of an arbitrary generic data",
"start": 284.66,
"duration": 5.63
},
{
"text": "structure, if you will.",
"start": 290.29,
"duration": 1.24
},
{
"text": "A generic way of just storing\nthings underneath the hood.",
"start": 291.53,
"duration": 2.93
},
{
"text": "Now, what do I mean by that?",
"start": 294.46,
"duration": 1.42
},
{
"text": "And why is this useful?",
"start": 295.88,
"duration": 1.51
},
{
"text": "Well, consider something like this.",
"start": 297.39,
"duration": 2.92
},
{
"text": "Consider having 8 doors,\nbehind which are some numbers.",
"start": 300.31,
"duration": 3.56
},
{
"text": "And the goal at hand\nis to solve a problem.",
"start": 303.87,
"duration": 2.07
},
{
"text": "Find a number behind these doors.",
"start": 305.94,
"duration": 2.3
},
{
"text": "Now, unfortunately, you\ndon't know in advance",
"start": 308.24,
"duration": 2.76
},
{
"text": "what numbers are behind those\ndoors and where they are.",
"start": 311.0,
"duration": 2.9
},
{
"text": "Indeed, that's why the doors are closed.",
"start": 313.9,
"duration": 1.74
},
{
"text": "But you know that, say, the number\n50 is somewhere behind those doors.",
"start": 315.64,
"duration": 4.39
},
{
"text": "So what do we do to actually find this?",
"start": 320.03,
"duration": 2.43
},
{
"text": "Well, let's go ahead and do this.",
"start": 322.46,
"duration": 1.41
},
{
"text": "Let me go ahead and summon up\na brave volunteer if you would.",
"start": 323.87,
"duration": 5.482
},
{
"text": "There's a CS50 stress\nball in it for you.",
"start": 329.352,
"duration": 1.708
},
{
"text": "OK, come on up.",
"start": 331.06,
"duration": 1.26
},
{
"text": "You want to come up on up over here?",
"start": 332.32,
"duration": 2.77
},
{
"text": "So we have not 8, but\nrather 7 doors here.",
"start": 335.09,
"duration": 4.1
},
{
"text": "Even easier.",
"start": 339.19,
"duration": 1.56
},
{
"text": "So 7/8 the size.",
"start": 340.75,
"duration": 0.751
},
{
"text": "And what's your name?",
"start": 341.501,
"duration": 0.874
},
{
"text": "AUDIENCE: Derek [INAUDIBLE].",
"start": 342.375,
"duration": 0.905
},
{
"text": "SPEAKER 1: Derek?",
"start": 343.28,
"duration": 0.45
},
{
"text": "OK.",
"start": 343.73,
"duration": 0.61
},
{
"text": "David, come on up.",
"start": 344.34,
"duration": 2.04
},
{
"text": "Nice to meet you.",
"start": 346.38,
"duration": 0.89
},
{
"text": "All right.",
"start": 347.27,
"duration": 0.82
},
{
"text": "So here we have 7 doors.",
"start": 348.09,
"duration": 1.55
},
{
"text": "And the goal at hand for you is\nto simply find the number 50.",
"start": 349.64,
"duration": 5.07
},
{
"text": "How do we find it?",
"start": 354.71,
"duration": 0.83
},
{
"text": "What are you going to do?",
"start": 355.54,
"duration": 1.715
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 357.255,
"duration": 2.325
},
{
"text": "SPEAKER 1: It's behind one\nof these doors, I think.",
"start": 359.58,
"duration": 2.735
},
{
"text": "AUDIENCE: All right.",
"start": 362.315,
"duration": 1.94
},
{
"text": "I'll just try a door?",
"start": 364.255,
"duration": 1.295
},
{
"text": "SPEAKER 1: Try a door.",
"start": 365.55,
"duration": 1.73
},
{
"text": "Not the door.",
"start": 367.28,
"duration": 0.7
},
{
"text": "So 16 turns up.",
"start": 367.98,
"duration": 1.27
},
{
"text": "OK.",
"start": 369.25,
"duration": 1.19
},
{
"text": "Stress ball gets one step away.",
"start": 370.44,
"duration": 3.4
},
{
"text": "Try another.",
"start": 373.84,
"duration": 1.27
},
{
"text": "42.",
"start": 375.11,
"duration": 1.52
},
{
"text": "Answer to life, the universe, and\neverything, but not this question.",
"start": 376.63,
"duration": 5.2
},
{
"text": "50.",
"start": 381.83,
"duration": 0.65
},
{
"text": "OK, very well done.",
"start": 382.48,
"duration": 1.33
},
{
"text": "So a round of applause if\nwe could for Derek here.",
"start": 383.81,
"duration": 2.6
},
{
"text": "Very nicely done.",
"start": 386.41,
"duration": 1.3
},
{
"text": "OK.",
"start": 387.71,
"duration": 0.5
},
{
"text": "And let's pause for just a moment.",
"start": 388.21,
"duration": 1.25
},
{
"text": "What was the algorithm?",
"start": 389.46,
"duration": 0.958
},
{
"text": "What was the set of instructions\nthat you used to find the number 50?",
"start": 390.418,
"duration": 3.102
},
{
"text": "AUDIENCE: Just try and see if I\ncould find any sort of arrangement.",
"start": 393.52,
"duration": 5.57
},
{
"text": "But otherwise, try random doors.",
"start": 399.09,
"duration": 1.787
},
{
"text": "SPEAKER 1: OK.",
"start": 400.877,
"duration": 0.583
},
{
"text": "So try random doors.",
"start": 401.46,
"duration": 0.97
},
{
"text": "And indeed, given no\nadditional information from me,",
"start": 402.43,
"duration": 2.675
},
{
"text": "that's the best you can do.",
"start": 405.105,
"duration": 1.125
},
{
"text": "Just try random doors.",
"start": 406.23,
"duration": 1.13
},
{
"text": "Or, if it's a little easier, just\ngo left to right or right to left.",
"start": 407.36,
"duration": 3.05
},
{
"text": "But random is perfectly equivalent\nto all of those algorithms",
"start": 410.41,
"duration": 2.75
},
{
"text": "because you don't know\nanything necessarily a priori.",
"start": 413.16,
"duration": 3.16
},
{
"text": "So how about for two stress balls?",
"start": 416.32,
"duration": 4.63
},
{
"text": "Find the number 50 this time,\nbut the additional ingredient",
"start": 420.95,
"duration": 2.702
},
{
"text": "is that we have taken\nthe time in advance",
"start": 423.652,
"duration": 1.708
},
{
"text": "to sort the numbers behind these doors.",
"start": 425.36,
"duration": 2.04
},
{
"text": "Does that change your\nthinking in any way?",
"start": 427.4,
"duration": 1.841
},
{
"text": "AUDIENCE: Well, I don't\nknow whether you're",
"start": 429.241,
"duration": 1.791
},
{
"text": "sorting increasing left or right.",
"start": 431.032,
"duration": 1.688
},
{
"text": "SPEAKER 1: Good.",
"start": 432.72,
"duration": 0.32
},
{
"text": "So good challenge.",
"start": 433.04,
"duration": 0.75
},
{
"text": "He doesn't know if we've sorted\nfrom left to right or right to left.",
"start": 433.79,
"duration": 3.25
},
{
"text": "Left to right.",
"start": 437.04,
"duration": 0.59
},
{
"text": "So generally, a computer scientist\nwhen he or she says \"sorted\"",
"start": 437.63,
"duration": 2.625
},
{
"text": "would say left to right.",
"start": 440.255,
"duration": 1.015
},
{
"text": "But reasonable question.",
"start": 441.27,
"duration": 1.38
},
{
"text": "AUDIENCE: Left to right\nincreasing or decreasing?",
"start": 442.65,
"duration": 1.2
},
{
"text": "SPEAKER 1: Left to right increasing.",
"start": 443.85,
"duration": 1.499
},
{
"text": "Yes.",
"start": 445.349,
"duration": 0.581
},
{
"text": "It would be left to right in any way.",
"start": 445.93,
"duration": 2.48
},
{
"text": "16.",
"start": 448.41,
"duration": 0.86
},
{
"text": "Not 50.",
"start": 449.27,
"duration": 0.5
},
{
"text": "So what are you going to do?",
"start": 449.77,
"duration": 1.166
},
{
"text": "AUDIENCE: Well, let's see.",
"start": 450.936,
"duration": 1.217
},
{
"text": "I know these have to be\nless, so I can remove them.",
"start": 452.153,
"duration": 2.357
},
{
"text": "SPEAKER 1: Good.",
"start": 454.51,
"duration": 0.666
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 455.176,
"duration": 2.284
},
{
"text": "SPEAKER 1: 42 is still not 50.",
"start": 457.46,
"duration": 2.43
},
{
"text": "And to the right.",
"start": 459.89,
"duration": 0.82
},
{
"text": "Very well done for Derek.",
"start": 460.71,
"duration": 1.9
},
{
"text": "OK, come on.",
"start": 462.61,
"duration": 1.11
},
{
"text": "OK.",
"start": 463.72,
"duration": 0.575
},
{
"text": "They're less impressed that time.",
"start": 464.295,
"duration": 1.375
},
{
"text": "So what did you do, though, that second\ntime that was actually more effective?",
"start": 465.67,
"duration": 4.76
},
{
"text": "I mean, frankly, at first glance it\nlooks like this approach was just as",
"start": 470.43,
"duration": 3.279
},
{
"text": "fast or just as slow\nas your first approach",
"start": 473.709,
"duration": 1.791
},
{
"text": "because it still took you through steps.",
"start": 475.5,
"duration": 1.666
},
{
"text": "AUDIENCE: So what I did was since\nyou told me that it was sorted left",
"start": 477.166,
"duration": 2.914
},
{
"text": "to right increasing, I decided to\nlook at the middle number first",
"start": 480.08,
"duration": 3.42
},
{
"text": "and see whether it was\ngreater than or less than--",
"start": 483.5,
"duration": 2.475
},
{
"text": "SPEAKER 1: Good",
"start": 485.975,
"duration": 0.625
},
{
"text": "AUDIENCE: --the target number.",
"start": 486.6,
"duration": 1.8
},
{
"text": "SPEAKER 1: Good.",
"start": 488.4,
"duration": 0.7
},
{
"text": "AUDIENCE: And since it was less than,\nI knew that all of these three values--",
"start": 489.1,
"duration": 2.88
},
{
"text": "SPEAKER 1: Wonderful.",
"start": 491.98,
"duration": 0.874
},
{
"text": "And indeed, are smaller by design.",
"start": 492.854,
"duration": 1.775
},
{
"text": "And so you can throw half of that\nproblem away, much like in week 0",
"start": 494.629,
"duration": 2.791
},
{
"text": "when we tore the phone book in half.",
"start": 497.42,
"duration": 1.5
},
{
"text": "You can throw half of that\nphone book away as well.",
"start": 498.92,
"duration": 2.72
},
{
"text": "So thank you very much for\nfinding us the number 50.",
"start": 501.64,
"duration": 2.25
},
{
"text": "So this is something that we\ndid see, indeed, in week 0.",
"start": 503.89,
"duration": 2.91
},
{
"text": "And it's what we would\ngenerally call binary search.",
"start": 506.8,
"duration": 2.52
},
{
"text": "Or more generally, just a\ndivide and conquer algorithm.",
"start": 509.32,
"duration": 3.2
},
{
"text": "But today, what we\nstart to do is to assess",
"start": 512.52,
"duration": 2.289
},
{
"text": "just how much better this actually is.",
"start": 514.809,
"duration": 2.291
},
{
"text": "And how we can go about finding\nthings more programmatically.",
"start": 517.1,
"duration": 3.85
},
{
"text": "So what Derek could have tried\nis what someone would generally",
"start": 520.95,
"duration": 4.45
},
{
"text": "call linear search.",
"start": 525.4,
"duration": 1.65
},
{
"text": "And as the name suggests,\nlinear, meaning line,",
"start": 527.05,
"duration": 2.07
},
{
"text": "you can just kind of solve a\nproblem from left to right.",
"start": 529.12,
"duration": 2.42
},
{
"text": "And indeed, while Derek\ndid take a random approach,",
"start": 531.54,
"duration": 2.58
},
{
"text": "it would have been\nfunctionally equivalent",
"start": 534.12,
"duration": 1.87
},
{
"text": "for him simply to go left to right or\nright to left and find the number 50.",
"start": 535.99,
"duration": 4.53
},
{
"text": "It's indeed there.",
"start": 540.52,
"duration": 0.947
},
{
"text": "So let's introduce some\npseudocode for this.",
"start": 541.467,
"duration": 1.833
},
{
"text": "And there is no one right\nway to implement pseudocode.",
"start": 543.3,
"duration": 3.29
},
{
"text": "Here is one of the most\nsuccinct ways I could come up",
"start": 546.59,
"duration": 2.35
},
{
"text": "with for expressing this kind\nof left to right approach.",
"start": 548.94,
"duration": 2.333
},
{
"text": "Or equivalently, right to left.",
"start": 551.273,
"duration": 1.507
},
{
"text": "For each element in the array, if\nelement you're looking for return true.",
"start": 552.78,
"duration": 5.41
},
{
"text": "And so this is a very common\nparadigm in programming.",
"start": 558.19,
"duration": 2.61
},
{
"text": "Just say something generally,\nlike for each element in an array.",
"start": 560.8,
"duration": 2.667
},
{
"text": "And the implication is that you\nwould generally go left to right,",
"start": 563.467,
"duration": 2.708
},
{
"text": "but it's equivalent to go right to left.",
"start": 566.175,
"duration": 1.675
},
{
"text": "And if we indeed see at\nsome location in that array",
"start": 567.85,
"duration": 4.01
},
{
"text": "that array of boxes, the element we're\nlooking for, we can just return true.",
"start": 571.86,
"duration": 4.27
},
{
"text": "And yet, here I have return false.",
"start": 576.13,
"duration": 2.77
},
{
"text": "But the indentation, so to\nspeak, is very different.",
"start": 578.9,
"duration": 2.92
},
{
"text": "Why have I aligned return\nfalse with the for loop",
"start": 581.82,
"duration": 3.34
},
{
"text": "here all the way on the left as opposed\nto it being aligned in the middle",
"start": 585.16,
"duration": 3.88
},
{
"text": "or one line deeper?",
"start": 589.04,
"duration": 3.73
},
{
"text": "Yeah.",
"start": 592.77,
"duration": 0.785
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 593.555,
"duration": 0.916
},
{
"text": "SPEAKER 1: Yeah.",
"start": 597.314,
"duration": 0.666
},
{
"text": "In order to denote that all\nof the indented elements",
"start": 597.98,
"duration": 1.96
},
{
"text": "are within the for loop.",
"start": 599.94,
"duration": 1.0
},
{
"text": "So it doesn't strictly\nmatter how much you indent.",
"start": 600.94,
"duration": 2.647
},
{
"text": "And indeed, in some\nlanguages, C among them,",
"start": 603.587,
"duration": 1.833
},
{
"text": "it doesn't matter that\nyou indent at all.",
"start": 605.42,
"duration": 2.48
},
{
"text": "But for the sake of good\nstyle and readability,",
"start": 607.9,
"duration": 2.84
},
{
"text": "we've indented this\nto convey to the human",
"start": 610.74,
"duration": 2.1
},
{
"text": "especially that this \"if\" is only\napplicable when you're inside",
"start": 612.84,
"duration": 4.27
},
{
"text": "of the for loop.",
"start": 617.11,
"duration": 0.69
},
{
"text": "This return is only applicable when\nyou're inside of this \"if\" condition.",
"start": 617.8,
"duration": 3.27
},
{
"text": "And this return false\nreally only happens",
"start": 621.07,
"duration": 3.1
},
{
"text": "as the very last step in this program if\nnothing else actually returns a value.",
"start": 624.17,
"duration": 4.95
},
{
"text": "So only if return true\nhappens does this program say,",
"start": 629.12,
"duration": 4.18
},
{
"text": "yes, I found the element\nyou're looking for.",
"start": 633.3,
"duration": 2.2
},
{
"text": "And you can think of this, therefore,\nas the sort of default case.",
"start": 635.5,
"duration": 2.81
},
{
"text": "Now, just to toss it out\nthere, why would this be wrong?",
"start": 638.31,
"duration": 5.17
},
{
"text": "Let me go ahead and\ntemporarily change this program",
"start": 643.48,
"duration": 4.74
},
{
"text": "to be a more familiar if/else block.",
"start": 648.22,
"duration": 2.87
},
{
"text": "So why is this seemingly logically fine?",
"start": 651.09,
"duration": 3.93
},
{
"text": "It's a valid puzzle piece\nif you will, a la scratch.",
"start": 655.02,
"duration": 3.23
},
{
"text": "But this program is now incorrect.",
"start": 658.25,
"duration": 1.525
},
{
"text": "Why?",
"start": 659.775,
"duration": 2.185
},
{
"text": "Yeah.",
"start": 661.96,
"duration": 0.762
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 662.722,
"duration": 0.916
},
{
"text": "SPEAKER 1: Once you hit\nit, it's automatically",
"start": 669.004,
"duration": 1.916
},
{
"text": "going to come out of the for loop when?",
"start": 670.92,
"duration": 1.2
},
{
"text": "Exactly.",
"start": 672.12,
"duration": 0.499
},
{
"text": "When will this come out of the for loop?",
"start": 672.619,
"duration": 2.113
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 674.732,
"duration": 1.942
},
{
"text": "SPEAKER 1: Good.",
"start": 676.674,
"duration": 0.666
},
{
"text": "So it's going to return false\nif the first element isn't",
"start": 677.34,
"duration": 3.09
},
{
"text": "what you're looking for.",
"start": 680.43,
"duration": 1.0
},
{
"text": "In so far as for each\nelement in an array",
"start": 681.43,
"duration": 1.939
},
{
"text": "kind of implies that you should\nbe looking from left to right",
"start": 683.369,
"duration": 2.541
},
{
"text": "or right to left, the\nfirst question you're",
"start": 685.91,
"duration": 2.02
},
{
"text": "asking yourself when looking\nin that first element",
"start": 687.93,
"duration": 2.1
},
{
"text": "is, is this the element\nyou're looking for?",
"start": 690.03,
"duration": 2.25
},
{
"text": "If it is, great.",
"start": 692.28,
"duration": 0.667
},
{
"text": "You're going to return true.",
"start": 692.947,
"duration": 1.166
},
{
"text": "And your answer is correct.",
"start": 694.113,
"duration": 1.217
},
{
"text": "But if it's not the\nelement you're looking",
"start": 695.33,
"duration": 1.8
},
{
"text": "for, you're executing else return false\nimmediately saying no, the element",
"start": 697.13,
"duration": 4.19
},
{
"text": "I'm looking for is not here.",
"start": 701.32,
"duration": 1.67
},
{
"text": "But when really the only question\nyou've asked is, is the element",
"start": 702.99,
"duration": 3.08
},
{
"text": "I'm looking for the\nvery first in the array?",
"start": 706.07,
"duration": 2.74
},
{
"text": "And so, indeed, this would\njust be logically incorrect",
"start": 708.81,
"duration": 2.25
},
{
"text": "because you might as well\nnot look at any of the array",
"start": 711.06,
"duration": 2.25
},
{
"text": "if you're only looking at\nthat very first element.",
"start": 713.31,
"duration": 2.88
},
{
"text": "So not what we intended.",
"start": 716.19,
"duration": 1.29
},
{
"text": "So indeed, that original\npseudocode is just fine.",
"start": 717.48,
"duration": 3.22
},
{
"text": "So alternatively, there's something\ncalled binary search, which",
"start": 720.7,
"duration": 3.03
},
{
"text": "Derek actually used intuitively\nfor his second approach,",
"start": 723.73,
"duration": 3.73
},
{
"text": "where he was told in advance that the\narray is sorted numerically from left",
"start": 727.46,
"duration": 4.24
},
{
"text": "to right.",
"start": 731.7,
"duration": 0.5
},
{
"text": "This gives him more information,\nmuch like I had in week 0",
"start": 732.2,
"duration": 2.416
},
{
"text": "when I searched a phone book\nthat I knew was alphabetical.",
"start": 734.616,
"duration": 3.134
},
{
"text": "And you can write this algorithm\nin any number of ways, too.",
"start": 737.75,
"duration": 2.54
},
{
"text": "I kind of borrowed the spirit of\nour Mike Smith algorithm from week 0",
"start": 740.29,
"duration": 3.947
},
{
"text": "and I proposed this.",
"start": 744.237,
"duration": 0.833
},
{
"text": "Look at the middle of the array.",
"start": 745.07,
"duration": 1.87
},
{
"text": "If element you're\nlooking for return true.",
"start": 746.94,
"duration": 2.09
},
{
"text": "We just get lucky if it's smack\ndab in the middle of the array.",
"start": 749.03,
"duration": 2.68
},
{
"text": "Else if the element is to\nthe left, because the element",
"start": 751.71,
"duration": 3.99
},
{
"text": "you're seeing in the middle is too big,\nthen search the left half of the array.",
"start": 755.7,
"duration": 4.69
},
{
"text": "Else if the element is to the\nright, as it was in Derek's case,",
"start": 760.39,
"duration": 3.3
},
{
"text": "search the right half of the\narray, else return false.",
"start": 763.69,
"duration": 4.16
},
{
"text": "But there is no go-to instruction here.",
"start": 767.85,
"duration": 2.27
},
{
"text": "And there's no line numbers.",
"start": 770.12,
"duration": 1.206
},
{
"text": "Recall from week 0 when we\nsearched for Mike Smith,",
"start": 771.326,
"duration": 2.124
},
{
"text": "I deliberately numbered\nall of the lines.",
"start": 773.45,
"duration": 1.93
},
{
"text": "And then I said, go back to\nstep 2 or 3 I think it was.",
"start": 775.38,
"duration": 4.08
},
{
"text": "Here, I seem to be cutting a corner.",
"start": 779.46,
"duration": 2.13
},
{
"text": "I'm just kind of waving\nmy hand and saying,",
"start": 781.59,
"duration": 2.106
},
{
"text": "search the left half of the list.",
"start": 783.696,
"duration": 1.374
},
{
"text": "Or, search the right half of the list.",
"start": 785.07,
"duration": 2.0
},
{
"text": "But what algorithm should we\nuse in either of these cases?",
"start": 787.07,
"duration": 3.66
},
{
"text": "How do you search the\nleft half of a list?",
"start": 793.62,
"duration": 2.03
},
{
"text": "How do you search the\nright half of a list?",
"start": 795.65,
"duration": 1.855
},
{
"text": "How do I do this?",
"start": 801.13,
"duration": 1.72
},
{
"text": "Well, where do I have an\nalgorithm for searching?",
"start": 802.85,
"duration": 2.49
},
{
"text": "Well, we saw one a moment ago.",
"start": 805.34,
"duration": 1.47
},
{
"text": "I've already got in my toolkit,\nso to speak, linear search.",
"start": 806.81,
"duration": 2.9
},
{
"text": "So I could certainly use that.",
"start": 809.71,
"duration": 1.31
},
{
"text": "But sort of cyclically,\nor sort of confusingly,",
"start": 811.02,
"duration": 3.15
},
{
"text": "I also have this other seemingly\nfancier, faster algorithm",
"start": 814.17,
"duration": 3.09
},
{
"text": "called binary search.",
"start": 817.26,
"duration": 1.2
},
{
"text": "And yet, I'm in the middle of defining\nbinary search with my pseudocode.",
"start": 818.46,
"duration": 4.46
},
{
"text": "And yet, here I am sort of trying\nto define myself with myself.",
"start": 822.92,
"duration": 3.234
},
{
"text": "You can't get away with this in English.",
"start": 826.154,
"duration": 1.666
},
{
"text": "If you're asked to\ndefine an English word",
"start": 827.82,
"duration": 1.74
},
{
"text": "and you use the word in the definition,\nusually a teacher or someone",
"start": 829.56,
"duration": 2.96
},
{
"text": "in a conversation will sort of\nverbally slap you on the wrist",
"start": 832.52,
"duration": 2.35
},
{
"text": "because you're not\nanswering the question.",
"start": 834.87,
"duration": 1.75
},
{
"text": "And yet somehow in programming,\nyou can get away with this.",
"start": 836.62,
"duration": 3.61
},
{
"text": "Somehow, you can get away with defining\na problem with a solution like this,",
"start": 840.23,
"duration": 5.62
},
{
"text": "and then using that same\nsolution inside of your solution",
"start": 845.85,
"duration": 2.95
},
{
"text": "because something is changing.",
"start": 848.8,
"duration": 2.66
},
{
"text": "This line here, search the\nleft half of the array,",
"start": 851.46,
"duration": 2.54
},
{
"text": "and this line here, search\nright half of the array,",
"start": 854.0,
"duration": 2.4
},
{
"text": "is not equivalent to asking\nthe same question again.",
"start": 856.4,
"duration": 4.24
},
{
"text": "Is this element in the array?",
"start": 860.64,
"duration": 1.65
},
{
"text": "What changes when I either search\nthe left half or the right half that",
"start": 862.29,
"duration": 4.38
},
{
"text": "makes this acceptable?",
"start": 866.67,
"duration": 2.26
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 868.93,
"duration": 1.427
},
{
"text": "SPEAKER 1: What's that?",
"start": 870.357,
"duration": 0.958
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 871.315,
"duration": 2.475
},
{
"text": "SPEAKER 1: Yes.",
"start": 873.79,
"duration": 0.93
},
{
"text": "That's the key ingredient.",
"start": 874.72,
"duration": 1.18
},
{
"text": "In so far as search left half\nand search right half imply",
"start": 875.9,
"duration": 3.8
},
{
"text": "search in the same way, but\nsearch a smaller problem,",
"start": 879.7,
"duration": 3.77
},
{
"text": "this problem will eventually stop.",
"start": 883.47,
"duration": 1.82
},
{
"text": "You're not going to get stuck\nin an infinite loop so to speak.",
"start": 885.29,
"duration": 2.583
},
{
"text": "Because eventually-- you\ncan't half something forever.",
"start": 887.873,
"duration": 2.467
},
{
"text": "You're eventually going to end\nup with one or zero elements.",
"start": 890.34,
"duration": 2.17
},
{
"text": "At which point, the\nanswer's going to be no.",
"start": 892.51,
"duration": 1.833
},
{
"text": "Return false, it's not here\nper the else condition.",
"start": 894.343,
"duration": 2.657
},
{
"text": "But these sort of reflexive\ncalls or inductive,",
"start": 897.0,
"duration": 4.78
},
{
"text": "or more properly here, recursive\ncalls-- the new buzzword",
"start": 901.78,
"duration": 3.48
},
{
"text": "for today-- means for a function, or in\nthis case pseudocode, to call itself.",
"start": 905.26,
"duration": 5.4
},
{
"text": "To use its own definition\nagain and again",
"start": 910.66,
"duration": 2.45
},
{
"text": "and again, which is bad instinctively,\nunless you keep doing it",
"start": 913.11,
"duration": 3.53
},
{
"text": "on smaller and smaller problems.",
"start": 916.64,
"duration": 2.3
},
{
"text": "And so this is a general\nprinciple, actually,",
"start": 918.94,
"duration": 2.31
},
{
"text": "that we're going to be able to leverage\nultimately, not only for searching but",
"start": 921.25,
"duration": 3.41
},
{
"text": "also, as we shall see, for sorting.",
"start": 924.66,
"duration": 3.49
},
{
"text": "So let's go ahead and\nlet me share actually",
"start": 928.15,
"duration": 2.48
},
{
"text": "how this example went last year.",
"start": 930.63,
"duration": 1.48
},
{
"text": "We're fortunate to capture\nsort of memories on film.",
"start": 932.11,
"duration": 2.52
},
{
"text": "And I thought it would\nbe fun to share this,",
"start": 934.63,
"duration": 1.985
},
{
"text": "when one of your predecessors\nin the class came up,",
"start": 936.615,
"duration": 2.525
},
{
"text": "was asked the exact same\nquestion, find us the number 50.",
"start": 939.14,
"duration": 2.92
},
{
"text": "But it didn't quite go\nas well as we hoped.",
"start": 942.06,
"duration": 2.61
},
{
"text": "Let's take a look at 2014.",
"start": 944.67,
"duration": 1.934
},
{
"text": "[AUDIO PLAYBACK]",
"start": 946.604,
"duration": 0.666
},
{
"text": "-All I want you to do now is\nto find for me and for us,",
"start": 947.27,
"duration": 3.65
},
{
"text": "really, the number 50\none step at a time.",
"start": 950.92,
"duration": 5.935
},
{
"text": "-Number 50?",
"start": 956.855,
"duration": 1.155
},
{
"text": "-The number 50.",
"start": 958.01,
"duration": 0.74
},
{
"text": "And you can reveal what's\nbehind each of these doors",
"start": 958.75,
"duration": 2.166
},
{
"text": "simply by touching it with a finger.",
"start": 960.916,
"duration": 3.184
},
{
"text": "Damn it.",
"start": 964.1,
"duration": 2.34
},
{
"text": "[APPLAUSE]",
"start": 966.44,
"duration": 2.151
},
{
"text": "[END PLAYBACK]",
"start": 968.591,
"duration": 0.656
},
{
"text": "SPEAKER 1: OK.",
"start": 969.247,
"duration": 0.583
},
{
"text": "So that didn't really\ndemonstrate anything that year.",
"start": 969.83,
"duration": 2.208
},
{
"text": "So we tried again, this time saying, all\nright, this time the array is sorted.",
"start": 972.038,
"duration": 4.202
},
{
"text": "What are you going to do this time if\nyou want to find the same number 50,",
"start": 976.24,
"duration": 3.24
},
{
"text": "but the array is now sorted?",
"start": 979.48,
"duration": 1.76
},
{
"text": "I thought I'd share this.",
"start": 981.24,
"duration": 1.463
},
{
"text": "[AUDIO PLAYBACK]",
"start": 982.703,
"duration": 0.887
},
{
"text": "-The goal now is to also find us the\nnumber 50, but do it algorithmically.",
"start": 983.59,
"duration": 4.31
},
{
"text": "And tell us how you're going about it.",
"start": 987.9,
"duration": 2.55
},
{
"text": "And if you find it, you keep the movie.",
"start": 990.45,
"duration": 2.17
},
{
"text": "If you don't find it, you give it back.",
"start": 992.62,
"duration": 1.924
},
{
"text": "-Man. [INAUDIBLE].",
"start": 994.544,
"duration": 1.828
},
{
"text": "OK.",
"start": 996.372,
"duration": 0.918
},
{
"text": "So I'm going to check the ends\nfirst to determine if there's-- oh.",
"start": 997.29,
"duration": 5.23
},
{
"text": "[APPLAUSE]",
"start": 1002.52,
"duration": 2.742
},
{
"text": "[END PLAYBACK]",
"start": 1005.761,
"duration": 0.929
},
{
"text": "SPEAKER 1: OK, now I feel a\nlittle bad because clearly we",
"start": 1006.69,
"duration": 1.38
},
{
"text": "used to give away movies and\nnow we give away stress balls.",
"start": 1008.07,
"duration": 2.64
},
{
"text": "But no one really has DVD players\nanymore, so it's OK probably.",
"start": 1010.71,
"duration": 3.12
},
{
"text": "And then, let me share one other\nclip back from our SD days.",
"start": 1013.83,
"duration": 3.32
},
{
"text": "Many years ago when Shawn, who\nhas since graduated, came up.",
"start": 1017.15,
"duration": 3.84
},
{
"text": "Was asked the same question.",
"start": 1020.99,
"duration": 1.2
},
{
"text": "So Derek, you are in this\nwonderful history of students",
"start": 1022.19,
"duration": 2.614
},
{
"text": "who have tried this demonstration.",
"start": 1024.804,
"duration": 1.416
},
{
"text": "This was, as you can, see before\nwe had touchscreen technology.",
"start": 1026.22,
"duration": 2.49
},
{
"text": "So we had sheets of\npaper up on the screen.",
"start": 1028.71,
"duration": 1.791
},
{
"text": "But the idea was the same.",
"start": 1030.501,
"duration": 1.389
},
{
"text": "And Shawn is perhaps one of\nour favorite memories in so far",
"start": 1031.89,
"duration": 3.24
},
{
"text": "as he, too, was asked to solve\nthe same problem in his way.",
"start": 1035.13,
"duration": 3.014
},
{
"text": "[AUDIO PLAYBACK]",
"start": 1038.144,
"duration": 0.666
},
{
"text": "-OK, so your task here,\nShawn, is the following.",
"start": 1038.81,
"duration": 3.33
},
{
"text": "I have hidden behind\nthese doors the number 7.",
"start": 1042.14,
"duration": 4.199
},
{
"text": "But tucked away in some of these doors\nas well are other non-negative numbers.",
"start": 1046.339,
"duration": 4.221
},
{
"text": "And your goal is to think\nof this top row of numbers",
"start": 1050.56,
"duration": 2.45
},
{
"text": "as just an array, or just a\nsequence of pieces of paper",
"start": 1053.01,
"duration": 2.87
},
{
"text": "with numbers behind them.",
"start": 1055.88,
"duration": 1.14
},
{
"text": "And your goal is only using the top\narray here, find me the number 7.",
"start": 1057.02,
"duration": 4.09
},
{
"text": "And we are then going to critique\nhow you go about doing it.",
"start": 1061.11,
"duration": 3.43
},
{
"text": "Find us the number 7, please.",
"start": 1064.54,
"duration": 1.671
},
{
"text": "No.",
"start": 1075.975,
"duration": 0.5
},
{
"text": "5, 19, 13.",
"start": 1080.04,
"duration": 4.043
},
{
"text": "It's not a trick question.",
"start": 1090.24,
"duration": 1.105
},
{
"text": "1.",
"start": 1094.775,
"duration": 0.5
},
{
"text": "At this point, your score is not very\ngood, so you might as well keep going.",
"start": 1100.168,
"duration": 3.166
},
{
"text": "3.",
"start": 1106.17,
"duration": 0.5
},
{
"text": "Go on.",
"start": 1111.84,
"duration": 0.69
},
{
"text": "-[INAUDIBLE].",
"start": 1112.53,
"duration": 0.677
},
{
"text": "-Frankly, I can't help but wonder\nwhat you're even thinking about.",
"start": 1113.207,
"duration": 2.75
},
{
"text": "Only the top row.",
"start": 1118.7,
"duration": 0.85
},
{
"text": "So you got 3 left.",
"start": 1119.55,
"duration": 0.95
},
{
"text": "So find me 7.",
"start": 1120.5,
"duration": 2.475
},
{
"text": "-[INAUDIBLE].",
"start": 1122.975,
"duration": 0.541
},
{
"text": "-17.",
"start": 1140.33,
"duration": 2.049
},
{
"text": "-[INAUDIBLE].",
"start": 1142.379,
"duration": 0.541
},
{
"text": "-7.",
"start": 1150.711,
"duration": 0.499
},
{
"text": "[END PLAYBACK]",
"start": 1151.21,
"duration": 1.695
},
{
"text": "SPEAKER 1: All right.",
"start": 1152.905,
"duration": 0.875
},
{
"text": "So we don't ask people\nto search for 7 anymore.",
"start": 1153.78,
"duration": 2.65
},
{
"text": "But this invites the\nquestion, how are we",
"start": 1156.43,
"duration": 2.74
},
{
"text": "allowed to have that assumption, right?",
"start": 1159.17,
"duration": 2.12
},
{
"text": "I've been assuming in week 0 that\nthe phone book was alphabetized.",
"start": 1161.29,
"duration": 3.35
},
{
"text": "And therefore, I can find Mike Smith\nreally fast in logarithmic time.",
"start": 1164.64,
"duration": 3.37
},
{
"text": "And we were just assuming\na moment ago that we",
"start": 1168.01,
"duration": 2.12
},
{
"text": "could find the number 50 super-fast\nbecause of divide and conquer.",
"start": 1170.13,
"duration": 3.62
},
{
"text": "Again, but only if\nthat array were sorted.",
"start": 1173.75,
"duration": 2.71
},
{
"text": "Indeed, Derek technically\njust got lucky in so far",
"start": 1176.46,
"duration": 2.22
},
{
"text": "as he found 50 the\nfirst time in 3 steps.",
"start": 1178.68,
"duration": 3.012
},
{
"text": "But it could have been as many as\n7 steps because it was, indeed,",
"start": 1181.692,
"duration": 2.708
},
{
"text": "a random algorithm.",
"start": 1184.4,
"duration": 0.96
},
{
"text": "Or even if he had used linear search.",
"start": 1185.36,
"duration": 2.0
},
{
"text": "So suppose we want to\nactually sort something.",
"start": 1187.36,
"duration": 3.34
},
{
"text": "So these are still used\non campus sometimes.",
"start": 1190.7,
"duration": 2.27
},
{
"text": "So these are blue books for exam period.",
"start": 1192.97,
"duration": 2.112
},
{
"text": "And suppose that we're at the end of\na semester and a bunch of students",
"start": 1195.082,
"duration": 2.958
},
{
"text": "have written their\nnames on these things.",
"start": 1198.04,
"duration": 1.708
},
{
"text": "And so A's and B's and C's and D's.",
"start": 1199.748,
"duration": 2.202
},
{
"text": "And suppose that they're handed\nin at somewhat random times.",
"start": 1201.95,
"duration": 2.64
},
{
"text": "There's always that kid who hands\nin his or her exam at an hour",
"start": 1204.59,
"duration": 2.43
},
{
"text": "into the 3-hour exam,\nand then most of them",
"start": 1207.02,
"duration": 1.57
},
{
"text": "come in around like 2 hours 45 minutes.",
"start": 1208.59,
"duration": 1.84
},
{
"text": "And so therefore, they're all\nin this pretty random arbitrary",
"start": 1210.43,
"duration": 4.04
},
{
"text": "order like this.",
"start": 1214.47,
"duration": 1.307
},
{
"text": "Actually, if I just them down like\nthat, they're not really random at all.",
"start": 1215.777,
"duration": 3.083
},
{
"text": "And so they're just\nin some random order.",
"start": 1218.86,
"duration": 2.04
},
{
"text": "And the goal at hand, ultimately,\nis for the head TF, for instance,",
"start": 1220.9,
"duration": 2.81
},
{
"text": "or the professor to actually\nsort all of these blue books",
"start": 1223.71,
"duration": 2.719
},
{
"text": "and come up with an alphabetical order\nso you can make sure that everyone",
"start": 1226.429,
"duration": 3.041
},
{
"text": "has actually submitted on time.",
"start": 1229.47,
"duration": 2.06
},
{
"text": "So how do we do this?",
"start": 1231.53,
"duration": 1.54
},
{
"text": "What is the algorithm\nwith which to do this?",
"start": 1233.07,
"duration": 2.84
},
{
"text": "Because indeed, if he\nor she, the professor,",
"start": 1235.91,
"duration": 2.17
},
{
"text": "later wants to find a certain\nname of the alphabet, like Smith,",
"start": 1238.08,
"duration": 4.15
},
{
"text": "it'd be nice if they don't have to sift\nthrough all 26, or all 100, or all 500",
"start": 1242.23,
"duration": 4.03
},
{
"text": "blue books.",
"start": 1246.26,
"duration": 0.5
},
{
"text": "They can just jump\nroughly to the middle,",
"start": 1246.76,
"duration": 1.71
},
{
"text": "and then divide and conquer\nand find Smith there after.",
"start": 1248.47,
"duration": 2.41
},
{
"text": "Can we get one volunteer to\ncome up and propose how to sort?",
"start": 1250.88,
"duration": 3.46
},
{
"text": "You want come on up?",
"start": 1254.34,
"duration": 0.97
},
{
"text": "Come on up.",
"start": 1255.31,
"duration": 0.64
},
{
"text": "What's your name?",
"start": 1255.95,
"duration": 0.43
},
{
"text": "AUDIENCE: Allison.",
"start": 1256.38,
"duration": 0.8
},
{
"text": "SPEAKER 1: Allison.",
"start": 1257.18,
"duration": 1.08
},
{
"text": "All right, come on up.",
"start": 1258.26,
"duration": 2.15
},
{
"text": "So if you've ever\nsorted something before,",
"start": 1260.41,
"duration": 1.75
},
{
"text": "now's your chance to\nshow that off, Allison.",
"start": 1262.16,
"duration": 1.941
},
{
"text": "All right.",
"start": 1264.101,
"duration": 0.499
},
{
"text": "So here are a whole bunch of blue books.",
"start": 1264.6,
"duration": 1.66
},
{
"text": "And I've just arbitrarily written\nnot names, but first letters",
"start": 1266.26,
"duration": 2.14
},
{
"text": "of the alphabet on them.",
"start": 1268.4,
"duration": 0.999
},
{
"text": "So go ahead and sort them.",
"start": 1269.399,
"duration": 1.381
},
{
"text": "AUDIENCE: So I start with a letter.",
"start": 1270.78,
"duration": 2.415
},
{
"text": "And if this is before\nthat, I just put it on top.",
"start": 1273.195,
"duration": 2.502
},
{
"text": "SPEAKER 1: OK.",
"start": 1275.697,
"duration": 0.583
},
{
"text": "So that's X and L. Gotcha.",
"start": 1276.28,
"duration": 1.614
},
{
"text": "AUDIENCE: And because Z is after that--",
"start": 1277.894,
"duration": 0.828
},
{
"text": "SPEAKER 1: There's Z.",
"start": 1278.722,
"duration": 0.828
},
{
"text": "AUDIENCE: --I put it below.",
"start": 1279.55,
"duration": 1.124
},
{
"text": "And D is here.",
"start": 1280.674,
"duration": 1.181
},
{
"text": "SPEAKER 1: OK.",
"start": 1281.855,
"duration": 0.584
},
{
"text": "So you seem to be taking them one at a\ntime and just dealing with the problem",
"start": 1282.439,
"duration": 3.207
},
{
"text": "then and now?",
"start": 1285.646,
"duration": 0.589
},
{
"text": "AUDIENCE: Yes.",
"start": 1286.235,
"duration": 0.365
},
{
"text": "SPEAKER 1: OK.",
"start": 1286.6,
"duration": 0.583
},
{
"text": "So that's J. What happens next?",
"start": 1287.183,
"duration": 1.567
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 1292.7,
"duration": 1.677
},
{
"text": "SPEAKER 1: OK.",
"start": 1294.377,
"duration": 0.583
},
{
"text": "That's K. K, L, good.",
"start": 1294.96,
"duration": 3.77
},
{
"text": "B, that's easy.",
"start": 1298.73,
"duration": 0.91
},
{
"text": "On top.",
"start": 1299.64,
"duration": 0.55
},
{
"text": "A, even easier.",
"start": 1300.19,
"duration": 1.02
},
{
"text": "On top.",
"start": 1301.21,
"duration": 1.036
},
{
"text": "AUDIENCE: Am I going to\nfinish this entire thing?",
"start": 1302.246,
"duration": 1.314
},
{
"text": "SPEAKER 1: Yes.",
"start": 1303.56,
"duration": 0.74
},
{
"text": "We need 13 more, give or take.",
"start": 1304.3,
"duration": 2.498
},
{
"text": "M and--",
"start": 1306.798,
"duration": 0.952
},
{
"text": "AUDIENCE: N.",
"start": 1307.75,
"duration": 0.5
},
{
"text": "SPEAKER 1: N, O. I didn't\ndo a very good job there.",
"start": 1308.25,
"duration": 3.51
},
{
"text": "U, V. OK, definitely not good.",
"start": 1311.76,
"duration": 2.97
},
{
"text": "Y. That's good.",
"start": 1314.73,
"duration": 1.06
},
{
"text": "It goes toward the end.",
"start": 1315.79,
"duration": 1.01
},
{
"text": "R, a little harder.",
"start": 1316.8,
"duration": 2.77
},
{
"text": "But this is actually a\ngood situation for us",
"start": 1319.57,
"duration": 1.92
},
{
"text": "to be in because-- you keep\ngoing, I'll keep talking.",
"start": 1321.49,
"duration": 2.208
},
{
"text": "So even as Allison is\nsorting this, she's",
"start": 1323.698,
"duration": 2.682
},
{
"text": "dealing with each of these\nblue books one at a time.",
"start": 1326.38,
"duration": 2.25
},
{
"text": "But notice what's happening\nto her right hand.",
"start": 1328.63,
"duration": 2.14
},
{
"text": "There literally is more and more work,\nit seems, happening in her right hand",
"start": 1330.77,
"duration": 3.77
},
{
"text": "because as she encounters R or now W,\nnot only does she need more thought,",
"start": 1334.54,
"duration": 3.58
},
{
"text": "she also needs to do more\nflipping to actually find",
"start": 1338.12,
"duration": 2.41
},
{
"text": "the right spot for W. This is H.\nShe's doing the same thing again.",
"start": 1340.53,
"duration": 2.98
},
{
"text": "So it feels like the algorithm\nhas started to slow down.",
"start": 1343.51,
"duration": 3.3
},
{
"text": "At first, it was pretty easy\nto just make a short list.",
"start": 1346.81,
"duration": 2.61
},
{
"text": "But now that the list\nis getting longer, it",
"start": 1349.42,
"duration": 2.01
},
{
"text": "feels like she's fixing a lot of\nwork, or finding a location is",
"start": 1351.43,
"duration": 3.91
},
{
"text": "getting harder and harder.",
"start": 1355.34,
"duration": 2.49
},
{
"text": "Or at least taking longer and longer.",
"start": 1357.83,
"duration": 1.83
},
{
"text": "Maybe the alphabet itself is\nnot that much more difficult.",
"start": 1359.66,
"duration": 2.51
},
{
"text": "Now, we have I. I can\nonly stall so much longer.",
"start": 1362.17,
"duration": 3.01
},
{
"text": "G.",
"start": 1365.18,
"duration": 0.5
},
{
"text": "AUDIENCE: Sorry.",
"start": 1365.68,
"duration": 0.29
},
{
"text": "SPEAKER 1: No, that's fine.",
"start": 1365.97,
"duration": 1.125
},
{
"text": "E, good.",
"start": 1367.095,
"duration": 0.505
},
{
"text": "OK.",
"start": 1367.6,
"duration": 0.5
},
{
"text": "So it's getting a little easier\nbecause we're at the beginning.",
"start": 1368.1,
"duration": 3.28
},
{
"text": "Sorted.",
"start": 1371.38,
"duration": 0.77
},
{
"text": "So what were you thinking?",
"start": 1372.15,
"duration": 1.39
},
{
"text": "What was that algorithm?",
"start": 1373.54,
"duration": 1.255
},
{
"text": "AUDIENCE: It was just take a\nletter, take another letter,",
"start": 1374.795,
"duration": 2.375
},
{
"text": "and then test to see if the\nletter is before or after.",
"start": 1377.17,
"duration": 3.294
},
{
"text": "SPEAKER 1: OK, good.",
"start": 1380.464,
"duration": 0.833
},
{
"text": "AUDIENCE: And then put it in the\ncorrect place on either side.",
"start": 1381.297,
"duration": 2.103
},
{
"text": "SPEAKER 1: Perfect.",
"start": 1383.4,
"duration": 0.43
},
{
"text": "So a perfect way of\nthinking about this as well.",
"start": 1383.83,
"duration": 1.82
},
{
"text": "So thank you so much.",
"start": 1385.65,
"duration": 0.945
},
{
"text": "AUDIENCE: Thank you.",
"start": 1386.595,
"duration": 0.405
},
{
"text": "SPEAKER 1: Very nicely done.",
"start": 1387.0,
"duration": 1.166
},
{
"text": "And suppose the problem's\na little harder.",
"start": 1388.166,
"duration": 2.144
},
{
"text": "I'll do this one myself here.",
"start": 1390.31,
"duration": 2.21
},
{
"text": "But suppose we have some playing cards.",
"start": 1392.52,
"duration": 2.22
},
{
"text": "And these are the type that\nprobably everyone here can see.",
"start": 1394.74,
"duration": 3.42
},
{
"text": "So here is a standard\ndeck of cards, including",
"start": 1398.16,
"duration": 4.09
},
{
"text": "the jokers, which we won't need.",
"start": 1402.25,
"duration": 1.636
},
{
"text": "How do you go about\nsorting things like this?",
"start": 1403.886,
"duration": 1.874
},
{
"text": "I don't know if-- actually,\nI didn't think in advance.",
"start": 1405.76,
"duration": 4.88
},
{
"text": "I should have shuffled these.",
"start": 1410.64,
"duration": 1.88
},
{
"text": "So if you want to shuffle these cards.",
"start": 1412.52,
"duration": 2.35
},
{
"text": "This is not going to end well.",
"start": 1414.87,
"duration": 2.11
},
{
"text": "OK.",
"start": 1416.98,
"duration": 0.73
},
{
"text": "So suppose we have all of these\ncards nicely shuffled here.",
"start": 1417.71,
"duration": 3.45
},
{
"text": "And I have before me a big\nproblem, a big pile of cards.",
"start": 1421.16,
"duration": 3.215
},
{
"text": "And the goal, for whatever reason,\nyou wanted to start the game",
"start": 1424.375,
"duration": 2.625
},
{
"text": "or you like to be orderly,\nis to sort the cards.",
"start": 1427.0,
"duration": 2.1
},
{
"text": "What's your algorithm going\nto be for sorting these cards?",
"start": 1429.1,
"duration": 4.081
},
{
"text": "What might you do?",
"start": 1433.181,
"duration": 0.749
},
{
"text": "Yeah.",
"start": 1437.56,
"duration": 0.702
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 1438.262,
"duration": 0.916
},
{
"text": "SPEAKER 1: Do them in\npiles based on the number.",
"start": 1441.651,
"duration": 1.999
},
{
"text": "OK, so here's the number 2.",
"start": 1443.65,
"duration": 1.51
},
{
"text": "So you want to make a\npile for all the 2's?",
"start": 1445.16,
"duration": 2.02
},
{
"text": "OK, so we can do that.",
"start": 1447.18,
"duration": 1.19
},
{
"text": "So here's a pile for all the 4's.",
"start": 1448.37,
"duration": 1.467
},
{
"text": "And let me make myself some more room.",
"start": 1449.837,
"duration": 1.583
},
{
"text": "So we can put 2's here.",
"start": 1451.42,
"duration": 1.2
},
{
"text": "4's here.",
"start": 1452.62,
"duration": 0.77
},
{
"text": "Here's a 3.",
"start": 1453.39,
"duration": 0.584
},
{
"text": "So I'm going to put this\nin between the 2 and the 4.",
"start": 1453.974,
"duration": 2.166
},
{
"text": "Here's a 5.",
"start": 1456.14,
"duration": 0.96
},
{
"text": "I'm going to put that over here.",
"start": 1457.1,
"duration": 1.43
},
{
"text": "And if I jump around, here's a Jack.",
"start": 1458.53,
"duration": 1.52
},
{
"text": "So this is going to go way over there.",
"start": 1460.05,
"duration": 2.09
},
{
"text": "7, 8.",
"start": 1462.14,
"duration": 1.0
},
{
"text": "6 can go over here.",
"start": 1463.14,
"duration": 1.59
},
{
"text": "Here's another 4, so I can put it here.",
"start": 1464.73,
"duration": 2.83
},
{
"text": "And I can bucketize all of the cards.",
"start": 1467.56,
"duration": 2.47
},
{
"text": "So this is good intuition because it\nmakes a pretty big problem, 52 cards,",
"start": 1470.03,
"duration": 4.11
},
{
"text": "a little more tenable.",
"start": 1474.14,
"duration": 1.149
},
{
"text": "You can just now flip through\nall of the cards one at a time,",
"start": 1475.289,
"duration": 2.541
},
{
"text": "or whatever you encounter first.",
"start": 1477.83,
"duration": 1.53
},
{
"text": "And just drop it in the correct bucket.",
"start": 1479.36,
"duration": 2.01
},
{
"text": "But that's, of course, not\ngoing to get you to the end.",
"start": 1481.37,
"duration": 2.291
},
{
"text": "Let's assume we fast\nforward to the ending.",
"start": 1483.661,
"duration": 1.869
},
{
"text": "And now I have these 13 piles\nfrom Ace all the way up to King.",
"start": 1485.53,
"duration": 4.64
},
{
"text": "What do I then do?",
"start": 1490.17,
"duration": 0.75
},
{
"text": "What's step 2?",
"start": 1490.92,
"duration": 2.24
},
{
"text": "AUDIENCE: Stack them.",
"start": 1493.16,
"duration": 0.98
},
{
"text": "SPEAKER 1: So I want to stack them.",
"start": 1494.14,
"duration": 1.03
},
{
"text": "So I can take all the 2's,\nall the 3's, all the 4's.",
"start": 1495.17,
"duration": 2.167
},
{
"text": "And I didn't specify\nearlier, one of the things",
"start": 1497.337,
"duration": 1.958
},
{
"text": "that complicates this problem with\ncards is that you have different suits.",
"start": 1499.295,
"duration": 3.115
},
{
"text": "And so if you really\nwant to be nit-picky,",
"start": 1502.41,
"duration": 1.75
},
{
"text": "maybe you want to keep\nall the suits the same,",
"start": 1504.16,
"duration": 1.916
},
{
"text": "which is like a nested\nsorting problem of some sort.",
"start": 1506.076,
"duration": 3.114
},
{
"text": "But this general idea of bucketizing\nin this way is good intuition,",
"start": 1509.19,
"duration": 3.57
},
{
"text": "but it clearly takes some time.",
"start": 1512.76,
"duration": 1.915
},
{
"text": "I mean, enough time that I'm not\ngoing to sort of drag this out",
"start": 1514.675,
"duration": 2.625
},
{
"text": "by sorting all of those cards myself.",
"start": 1517.3,
"duration": 1.88
},
{
"text": "And therein lies the point, though.",
"start": 1519.18,
"duration": 1.81
},
{
"text": "Even though in week 0 with Mike\nSmith, we had that sorted phone book.",
"start": 1520.99,
"duration": 2.95
},
{
"text": "And even though a moment ago,\nDerek, albeit with a few numbers,",
"start": 1523.94,
"duration": 2.94
},
{
"text": "had them already presorted,\nsorting takes time.",
"start": 1526.88,
"duration": 3.64
},
{
"text": "And even when we were just sorting\nthe blue books alphabetically,",
"start": 1530.52,
"duration": 3.42
},
{
"text": "even though it felt pretty fast, pretty\nobvious, it starts to drag eventually.",
"start": 1533.94,
"duration": 3.74
},
{
"text": "And god forbid there\nwere more than 26 books.",
"start": 1537.68,
"duration": 1.92
},
{
"text": "Maybe there were 260 books, or\n2,600 books, or 2 million books.",
"start": 1539.6,
"duration": 5.32
},
{
"text": "Or web pages.",
"start": 1544.92,
"duration": 1.19
},
{
"text": "Or database records.",
"start": 1546.11,
"duration": 1.63
},
{
"text": "Any number of problems in this\nworld now require sorting sometimes.",
"start": 1547.74,
"duration": 3.674
},
{
"text": "Whether it's on Google, or\nFacebook, or your own computer.",
"start": 1551.414,
"duration": 2.416
},
{
"text": "It feels like we need a good algorithm\nfor actually doing that sorting.",
"start": 1553.83,
"duration": 3.36
},
{
"text": "So how can we go about doing that,\nnot just with blue books, not",
"start": 1557.19,
"duration": 3.05
},
{
"text": "just with cards, but more generally?",
"start": 1560.24,
"duration": 2.3
},
{
"text": "Well, let's try to frame the\nproblem first with a simpler world.",
"start": 1562.54,
"duration": 3.78
},
{
"text": "In fact, we can generalize\nblue books and playing cards",
"start": 1566.32,
"duration": 3.92
},
{
"text": "as really just numbers.",
"start": 1570.24,
"duration": 1.06
},
{
"text": "Or some piece of data that there is\na defined order or sequence to them.",
"start": 1571.3,
"duration": 4.55
},
{
"text": "And suppose I have these numbers here.",
"start": 1575.85,
"duration": 1.78
},
{
"text": "How do I actually go about\nsorting this many numbers?",
"start": 1577.63,
"duration": 3.469
},
{
"text": "Well, for this-- and this\nwill be our last chance",
"start": 1581.099,
"duration": 2.041
},
{
"text": "for audience participation here.",
"start": 1583.14,
"duration": 1.62
},
{
"text": "I need eight brave volunteers\nto actually come on up.",
"start": 1584.76,
"duration": 3.13
},
{
"text": "All right, so 1, 2.",
"start": 1587.89,
"duration": 0.863
},
{
"text": "This is what everyone's\nbeen waiting for.",
"start": 1588.753,
"duration": 1.708
},
{
"text": "1, 2, 3, 4, 5, 6, 7, and 8.",
"start": 1590.461,
"duration": 6.719
},
{
"text": "Thank you.",
"start": 1597.18,
"duration": 0.5
},
{
"text": "Come on up.",
"start": 1597.68,
"duration": 1.52
},
{
"text": "And I will meet you over here.",
"start": 1599.2,
"duration": 1.58
},
{
"text": "All right.",
"start": 1607.46,
"duration": 0.73
},
{
"text": "Come on over here.",
"start": 1608.19,
"duration": 0.75
},
{
"text": "If you want to grab two music stands.",
"start": 1608.94,
"duration": 1.541
},
{
"text": "OK.",
"start": 1613.4,
"duration": 0.5
},
{
"text": "So let's go ahead and turn these\naround like this if you could,",
"start": 1613.9,
"duration": 2.19
},
{
"text": "as though the music's\ngoing to face the audience.",
"start": 1616.09,
"duration": 2.041
},
{
"text": "OK.",
"start": 1621.94,
"duration": 2.77
},
{
"text": "All right.",
"start": 1624.71,
"duration": 0.5
},
{
"text": "And let me go ahead and give you sheets\nof paper, and then we'll resume here.",
"start": 1625.21,
"duration": 4.01
},
{
"text": "All right.",
"start": 1629.22,
"duration": 0.5
},
{
"text": "So here is our eighth music stand.",
"start": 1629.72,
"duration": 2.05
},
{
"text": "And what we have here\nis 8 pieces of paper.",
"start": 1631.77,
"duration": 2.427
},
{
"text": "And each of you guys is going to take on\nthe role of a certain number right now.",
"start": 1634.197,
"duration": 3.333
},
{
"text": "So I'm going to go ahead and give\neach of you a number in sorted order",
"start": 1637.53,
"duration": 5.17
},
{
"text": "initially, but that would be too easy.",
"start": 1642.7,
"duration": 2.59
},
{
"text": "So if you don't mind, let's go ahead and\narrange yourselves behind these music",
"start": 1645.29,
"duration": 5.444
},
{
"text": "stands in the same order\nthat you see on the screen.",
"start": 1650.734,
"duration": 2.166
},
{
"text": "So on the left end here near\nme should be the number 4.",
"start": 1652.9,
"duration": 3.02
},
{
"text": "Then, 2.",
"start": 1655.92,
"duration": 1.76
},
{
"text": "Then, 6.",
"start": 1657.68,
"duration": 1.7
},
{
"text": "Then, 8.",
"start": 1659.38,
"duration": 0.51
},
{
"text": "Good job.",
"start": 1659.89,
"duration": 0.84
},
{
"text": "Then, 1.",
"start": 1660.73,
"duration": 0.85
},
{
"text": "Then, 3.",
"start": 1661.58,
"duration": 1.03
},
{
"text": "Then, 7.",
"start": 1662.61,
"duration": 0.92
},
{
"text": "Then, 5.",
"start": 1663.53,
"duration": 0.57
},
{
"text": "All right.",
"start": 1664.1,
"duration": 0.5
},
{
"text": "And you can put the\nnumbers on the music stand",
"start": 1664.6,
"duration": 1.76
},
{
"text": "there, but just move\nthem with you as you go.",
"start": 1666.36,
"duration": 1.875
},
{
"text": "So now the question is, here\nis a seemingly random list",
"start": 1668.235,
"duration": 3.435
},
{
"text": "in just some order I came up\nwith somewhat arbitrarily.",
"start": 1671.67,
"duration": 2.3
},
{
"text": "And I want now to sort my list.",
"start": 1673.97,
"duration": 3.2
},
{
"text": "How do I go about doing it?",
"start": 1677.17,
"duration": 1.3
},
{
"text": "What would you propose?",
"start": 1678.47,
"duration": 1.77
},
{
"text": "The goal is to get from 1 to 8.",
"start": 1680.24,
"duration": 2.95
},
{
"text": "What are our possible approaches here?",
"start": 1683.19,
"duration": 4.74
},
{
"text": "Oh, you want-- sure, OK.",
"start": 1687.93,
"duration": 1.28
},
{
"text": "We'll just do it over here.",
"start": 1689.21,
"duration": 1.124
},
{
"text": "AUDIENCE: Take out the smallest number.",
"start": 1690.334,
"duration": 1.856
},
{
"text": "SPEAKER 1: OK.",
"start": 1692.19,
"duration": 0.583
},
{
"text": "AUDIENCE: Take it, shift\neveryone else down.",
"start": 1692.773,
"duration": 1.858
},
{
"text": "Have the smallest number\nin the first place.",
"start": 1694.631,
"duration": 1.519
},
{
"text": "SPEAKER 1: OK, good.",
"start": 1696.15,
"duration": 0.686
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 1696.836,
"duration": 0.916
},
{
"text": "SPEAKER 1: So let's\ngo ahead and do that.",
"start": 1697.752,
"duration": 1.962
},
{
"text": "For those tuning in at home,\nwhat's your name again?",
"start": 1699.714,
"duration": 2.166
},
{
"text": "AUDIENCE: Allison.",
"start": 1701.88,
"duration": 0.61
},
{
"text": "SPEAKER 1: Allison.",
"start": 1702.49,
"duration": 0.46
},
{
"text": "And?",
"start": 1702.95,
"duration": 0.54
},
{
"text": "AUDIENCE: Alex.",
"start": 1703.49,
"duration": 0.37
},
{
"text": "SPEAKER 1: Alex.",
"start": 1703.86,
"duration": 0.412
},
{
"text": "AUDIENCE: Adam.",
"start": 1704.272,
"duration": 0.625
},
{
"text": "SPEAKER 1: Adam.",
"start": 1704.897,
"duration": 0.673
},
{
"text": "AUDIENCE: Brandon.",
"start": 1705.57,
"duration": 0.75
},
{
"text": "SPEAKER 1: Brandon.",
"start": 1706.32,
"duration": 0.365
},
{
"text": "AUDIENCE: Joseph.",
"start": 1706.685,
"duration": 0.365
},
{
"text": "SPEAKER 1: Joseph.",
"start": 1707.05,
"duration": 0.4
},
{
"text": "AUDIENCE: Vicky.",
"start": 1707.45,
"duration": 0.305
},
{
"text": "SPEAKER 1: Vicky.",
"start": 1707.755,
"duration": 0.765
},
{
"text": "AUDIENCE: [? Arpin. ?]",
"start": 1708.52,
"duration": 0.27
},
{
"text": "SPEAKER 1: [? Arpin. ?]",
"start": 1708.79,
"duration": 0.27
},
{
"text": "AUDIENCE: Derek.",
"start": 1709.06,
"duration": 0.666
},
{
"text": "SPEAKER 1: Derek.",
"start": 1709.726,
"duration": 0.784
},
{
"text": "OK.",
"start": 1710.51,
"duration": 0.66
},
{
"text": "So now, because that all\njust was too much to absorb.",
"start": 1711.17,
"duration": 3.13
},
{
"text": "Number 1 is now the\nfirst smallest element",
"start": 1714.3,
"duration": 4.15
},
{
"text": "according to the proposed algorithm.",
"start": 1718.45,
"duration": 1.5
},
{
"text": "So what are we going to\ndo exactly with number 1?",
"start": 1719.95,
"duration": 2.22
},
{
"text": "AUDIENCE: He's going to [INAUDIBLE].",
"start": 1722.17,
"duration": 1.499
},
{
"text": "We're [INAUDIBLE].",
"start": 1723.669,
"duration": 1.218
},
{
"text": "SPEAKER 1: OK, good.",
"start": 1724.887,
"duration": 0.833
},
{
"text": "So pop back if you would.",
"start": 1725.72,
"duration": 1.39
},
{
"text": "You guys are going to shift\nthree places this way.",
"start": 1727.11,
"duration": 2.104
},
{
"text": "And we're going to insert number\n1 at the beginning of the list.",
"start": 1729.214,
"duration": 2.666
},
{
"text": "All right, so what's the\nnext step just to be clear?",
"start": 1731.88,
"duration": 1.5
},
{
"text": "AUDIENCE: Number 2 is going to pop up.",
"start": 1733.38,
"duration": 2.03
},
{
"text": "SPEAKER 1: Good.",
"start": 1735.41,
"duration": 0.666
},
{
"text": "AUDIENCE: I'm going to shift down.",
"start": 1736.076,
"duration": 0.912
},
{
"text": "Number 1 is going to stay in place.",
"start": 1736.988,
"duration": 0.456
},
{
"text": "SPEAKER 1: Good.",
"start": 1737.444,
"duration": 0.456
},
{
"text": "So we find the next smallest\nelement, which happens to be 2.",
"start": 1737.9,
"duration": 2.37
},
{
"text": "We insert him at the\nbeginning of the list here.",
"start": 1740.27,
"duration": 2.07
},
{
"text": "And now, we move on to the\nnumber 3 problem Excellent.",
"start": 1742.34,
"duration": 2.47
},
{
"text": "So pop back.",
"start": 1744.81,
"duration": 1.56
},
{
"text": "Shift.",
"start": 1746.37,
"duration": 1.39
},
{
"text": "And insert.",
"start": 1747.76,
"duration": 0.55
},
{
"text": "Good.",
"start": 1748.31,
"duration": 0.5
},
{
"text": "4, we got lucky.",
"start": 1748.81,
"duration": 0.809
},
{
"text": "So we don't have to do\nany extra work here.",
"start": 1749.619,
"duration": 1.791
},
{
"text": "So that's a freebie.",
"start": 1751.41,
"duration": 0.833
},
{
"text": "Now we look for 5.",
"start": 1752.243,
"duration": 0.837
},
{
"text": "Oh, there's 5 at the end.",
"start": 1753.08,
"duration": 3.34
},
{
"text": "Good.",
"start": 1756.42,
"duration": 1.14
},
{
"text": "And now 6.",
"start": 1757.56,
"duration": 0.99
},
{
"text": "We got lucky.",
"start": 1758.55,
"duration": 0.77
},
{
"text": "7 and 8, we need to fix that.",
"start": 1759.32,
"duration": 2.01
},
{
"text": "OK, good.",
"start": 1761.33,
"duration": 0.83
},
{
"text": "So I like this.",
"start": 1762.16,
"duration": 0.89
},
{
"text": "It felt pretty fast.",
"start": 1763.05,
"duration": 1.02
},
{
"text": "Though, to be fair, the\nlist is pretty short.",
"start": 1764.07,
"duration": 2.1
},
{
"text": "But we were doing kind of a lot of work.",
"start": 1766.17,
"duration": 2.167
},
{
"text": "In fact, that was perfect the fact\nthat number 1 was all the way over here",
"start": 1768.337,
"duration": 3.083
},
{
"text": "because we shifted 3 humans.",
"start": 1771.42,
"duration": 1.762
},
{
"text": "And can you guys reset\nfor just a moment?",
"start": 1773.182,
"duration": 1.708
},
{
"text": "Let me propose an alternative approach.",
"start": 1774.89,
"duration": 1.89
},
{
"text": "So if number 1 is in the middle here\nand really belongs all the way there",
"start": 1776.78,
"duration": 4.15
},
{
"text": "on the left, we went\nto great lengths, it",
"start": 1780.93,
"duration": 2.8
},
{
"text": "seems, to shift all of these volunteers\nto the left, which is a lot of steps.",
"start": 1783.73,
"duration": 3.292
},
{
"text": "Because at the end of the day,\nlet's assume for today's purposes,",
"start": 1787.022,
"duration": 2.708
},
{
"text": "that a computer can only\ndo one thing at once.",
"start": 1789.73,
"duration": 2.061
},
{
"text": "So even though all of you\nhumans moved pretty quickly,",
"start": 1791.791,
"duration": 2.249
},
{
"text": "that was really like one of you moved.",
"start": 1794.04,
"duration": 1.88
},
{
"text": "Then, the next of you moved.",
"start": 1795.92,
"duration": 1.2
},
{
"text": "Then, the next of you moved.",
"start": 1797.12,
"duration": 1.07
},
{
"text": "Then, the next.",
"start": 1798.19,
"duration": 0.63
},
{
"text": "So that was like 4 total steps just\nto put number 1 on the end there.",
"start": 1798.82,
"duration": 4.057
},
{
"text": "Let me propose this.",
"start": 1802.877,
"duration": 0.833
},
{
"text": "1, can you pop out again?",
"start": 1803.71,
"duration": 1.65
},
{
"text": "Now, this list, so far as I'm\nconcerned as the computer,",
"start": 1805.36,
"duration": 2.9
},
{
"text": "is perfectly random from the get-go.",
"start": 1808.26,
"duration": 2.26
},
{
"text": "So why do I even care\nthat you guys move?",
"start": 1810.52,
"duration": 2.96
},
{
"text": "I haven't even looked at\nthe rest of these elements",
"start": 1813.48,
"duration": 2.869
},
{
"text": "yet or done anything with them.",
"start": 1816.349,
"duration": 1.291
},
{
"text": "Why don't I just evict number\n4 where number 1 belongs?",
"start": 1817.64,
"duration": 2.684
},
{
"text": "If you want to go over here.",
"start": 1820.324,
"duration": 1.166
},
{
"text": "And if the list is already\nrandomly sorted in the beginning,",
"start": 1821.49,
"duration": 2.499
},
{
"text": "well, then fine.",
"start": 1823.989,
"duration": 0.761
},
{
"text": "4, you're going to go over here.",
"start": 1824.75,
"duration": 1.333
},
{
"text": "So I've made the problem no worse,\nbut I have made it slightly better",
"start": 1826.083,
"duration": 3.027
},
{
"text": "by putting 1 on the end.",
"start": 1829.11,
"duration": 1.385
},
{
"text": "Now I'm going to go ahead and select\nthe next smallest element again.",
"start": 1830.495,
"duration": 2.875
},
{
"text": "2, I got lucky.",
"start": 1833.37,
"duration": 1.34
},
{
"text": "Now, I'm going to look for\nthe next smallest element.",
"start": 1834.71,
"duration": 2.58
},
{
"text": "3 indeed is the smallest.",
"start": 1837.29,
"duration": 1.524
},
{
"text": "So let me do the same thing.",
"start": 1838.814,
"duration": 1.166
},
{
"text": "3, if you could pop back.",
"start": 1839.98,
"duration": 1.3
},
{
"text": "6, you're out of there.",
"start": 1841.28,
"duration": 2.11
},
{
"text": "And notice that we're doing less work.",
"start": 1843.39,
"duration": 1.69
},
{
"text": "Now, the humans are moving a little\nfarther physically, but that's fine.",
"start": 1845.08,
"duration": 3.0
},
{
"text": "The computer can just move values\naround in memory pretty fast.",
"start": 1848.08,
"duration": 3.51
},
{
"text": "But I've moved fewer of you.",
"start": 1851.59,
"duration": 1.63
},
{
"text": "So this is a slight optimization.",
"start": 1853.22,
"duration": 1.55
},
{
"text": "It turns out this isn't\nfundamentally better as we'll see.",
"start": 1854.77,
"duration": 2.75
},
{
"text": "But it's this instinct\nthat you should appreciate",
"start": 1857.52,
"duration": 2.16
},
{
"text": "of trying to do the least\namount of work possible.",
"start": 1859.68,
"duration": 2.083
},
{
"text": "Because otherwise, it's going to add up.",
"start": 1861.763,
"duration": 2.507
},
{
"text": "Let's try another one.",
"start": 1864.27,
"duration": 2.02
},
{
"text": "Well, let me clarify one thing then.",
"start": 1866.29,
"duration": 1.66
},
{
"text": "So what am I doing on each\niteration of this algorithm?",
"start": 1867.95,
"duration": 3.1
},
{
"text": "As you suggested, I'm\nselecting the smallest element.",
"start": 1871.05,
"duration": 3.21
},
{
"text": "But the only catch is, if I'm\nnow looking for the next smallest",
"start": 1874.26,
"duration": 3.01
},
{
"text": "element, that's going to be 4.",
"start": 1877.27,
"duration": 1.7
},
{
"text": "But I'm only sure that it's\n4 once I get to the end",
"start": 1878.97,
"duration": 2.42
},
{
"text": "and realize, yep, that was the\nsmallest element and then I act.",
"start": 1881.39,
"duration": 3.0
},
{
"text": "So once we fix that problem--\nif you guys want to switch--",
"start": 1884.39,
"duration": 3.11
},
{
"text": "I start again over here.",
"start": 1887.5,
"duration": 1.485
},
{
"text": "And I have to find the\nnext smallest element.",
"start": 1888.985,
"duration": 1.875
},
{
"text": "And let's see, 8 is pretty big.",
"start": 1890.86,
"duration": 1.82
},
{
"text": "6 is smaller.",
"start": 1892.68,
"duration": 0.69
},
{
"text": "Good.",
"start": 1893.37,
"duration": 0.5
},
{
"text": "7, not smaller.",
"start": 1893.87,
"duration": 1.95
},
{
"text": "But only once I get to the end do I\nrealize, oh, here is the smallest.",
"start": 1895.82,
"duration": 3.07
},
{
"text": "So in short, to find\nthe smallest element",
"start": 1898.89,
"duration": 2.56
},
{
"text": "as you proposed again and again, I have\nto keep going through the whole list",
"start": 1901.45,
"duration": 4.349
},
{
"text": "because it might be\nall the way at the end.",
"start": 1905.799,
"duration": 1.791
},
{
"text": "We, humans, have the\nadvantage of just kind",
"start": 1907.59,
"duration": 1.49
},
{
"text": "of looking, sort of taking\na step back and saying,",
"start": 1909.08,
"duration": 2.19
},
{
"text": "OK, this is obviously unsorted.",
"start": 1911.27,
"duration": 1.44
},
{
"text": "I know where everything is.",
"start": 1912.71,
"duration": 1.17
},
{
"text": "A computer can only look\nat one number at a time,",
"start": 1913.88,
"duration": 3.05
},
{
"text": "one element of an array at a time.",
"start": 1916.93,
"duration": 1.99
},
{
"text": "So let's try a fundamentally\ndifferent approach.",
"start": 1918.92,
"duration": 2.0
},
{
"text": "If you guys could reset to\nyour original 8 locations.",
"start": 1920.92,
"duration": 2.53
},
{
"text": "Let me propose that we\njust looked at an algorithm",
"start": 1923.45,
"duration": 4.27
},
{
"text": "that we'll call selection sort.",
"start": 1927.72,
"duration": 1.54
},
{
"text": "Selection sort in so far as you\niteratively again and again select",
"start": 1929.26,
"duration": 4.24
},
{
"text": "the next smallest element.",
"start": 1933.5,
"duration": 1.63
},
{
"text": "Let's now do an approach that\nwe'll call bubble sort, which",
"start": 1935.13,
"duration": 4.46
},
{
"text": "has sort of the visual effect of numbers\nbubbling up over time as follows.",
"start": 1939.59,
"duration": 4.277
},
{
"text": "You know what?",
"start": 1943.867,
"duration": 0.583
},
{
"text": "I'm just going to look,\nnot at the whole list",
"start": 1944.45,
"duration": 1.76
},
{
"text": "because it felt like that was\ncreating a lot of work for me.",
"start": 1946.21,
"duration": 2.51
},
{
"text": "I'm going to look at 2\nnumbers at a time, 4 and 2.",
"start": 1948.72,
"duration": 2.54
},
{
"text": "Are these in order or out of order?",
"start": 1951.26,
"duration": 1.63
},
{
"text": "Obviously.",
"start": 1952.89,
"duration": 1.44
},
{
"text": "So they're out of order.",
"start": 1954.33,
"duration": 1.0
},
{
"text": "So you know what?",
"start": 1955.33,
"duration": 0.48
},
{
"text": "I don't care about the\nrest of the problem.",
"start": 1955.81,
"duration": 1.791
},
{
"text": "Let me just swap you two.",
"start": 1957.601,
"duration": 1.619
},
{
"text": "All right.",
"start": 1959.22,
"duration": 0.5
},
{
"text": "Now, let me take one step.",
"start": 1959.72,
"duration": 1.51
},
{
"text": "Look at 4 and 6.",
"start": 1961.23,
"duration": 0.94
},
{
"text": "In order or out of order?",
"start": 1962.17,
"duration": 1.32
},
{
"text": "In order.",
"start": 1963.49,
"duration": 0.53
},
{
"text": "So I'm going to leave it be.",
"start": 1964.02,
"duration": 1.24
},
{
"text": "6 and 8?",
"start": 1965.26,
"duration": 0.86
},
{
"text": "In order.",
"start": 1966.12,
"duration": 0.81
},
{
"text": "8 and 1?",
"start": 1966.93,
"duration": 0.55
},
{
"text": "Not in order.",
"start": 1967.48,
"duration": 0.76
},
{
"text": "So let me swap that again.",
"start": 1968.24,
"duration": 1.555
},
{
"text": "8 and 3?",
"start": 1969.795,
"duration": 1.005
},
{
"text": "Out of order.",
"start": 1970.8,
"duration": 0.57
},
{
"text": "Let me swap that again.",
"start": 1971.37,
"duration": 1.52
},
{
"text": "8 and 7?",
"start": 1972.89,
"duration": 1.219
},
{
"text": "Out of order.",
"start": 1974.109,
"duration": 0.541
},
{
"text": "Let me swap that again.",
"start": 1974.65,
"duration": 1.78
},
{
"text": "8 and 5?",
"start": 1976.43,
"duration": 0.969
},
{
"text": "Out of order.",
"start": 1977.399,
"duration": 0.541
},
{
"text": "Let me swap that again.",
"start": 1977.94,
"duration": 1.69
},
{
"text": "And now, what has happened?",
"start": 1979.63,
"duration": 1.16
},
{
"text": "Is the list sorted because I\nfixed all the pairwise mistakes?",
"start": 1980.79,
"duration": 5.51
},
{
"text": "So obviously not.",
"start": 1986.3,
"duration": 1.01
},
{
"text": "But is it better, the list?",
"start": 1987.31,
"duration": 1.412
},
{
"text": "Why is it better?",
"start": 1988.722,
"duration": 0.708
},
{
"text": "Derek.",
"start": 1989.43,
"duration": 0.66
},
{
"text": "AUDIENCE: Because now you have\none less element to worry about.",
"start": 1990.09,
"duration": 2.02
},
{
"text": "SPEAKER 1: Yeah, exactly.",
"start": 1992.11,
"duration": 1.041
},
{
"text": "8 bubbled all the way up\nto the top, if you will.",
"start": 1993.151,
"duration": 2.879
},
{
"text": "So now he is effectively done.",
"start": 1996.03,
"duration": 1.83
},
{
"text": "And frankly, every other\nnumber that's smaller",
"start": 1997.86,
"duration": 1.98
},
{
"text": "bubbled one step closer to its position.",
"start": 1999.84,
"duration": 2.899
},
{
"text": "So we've taken one big pass through this\nto solve at least one of the problems.",
"start": 2002.739,
"duration": 3.291
},
{
"text": "And now maximally, 7 problems remain.",
"start": 2006.03,
"duration": 2.58
},
{
"text": "So let me go back to the end here.",
"start": 2008.61,
"duration": 1.86
},
{
"text": "And let me look at pairwise.",
"start": 2010.47,
"duration": 1.31
},
{
"text": "2 and 4?",
"start": 2011.78,
"duration": 0.55
},
{
"text": "You're good.",
"start": 2012.33,
"duration": 0.55
},
{
"text": "4 and 6?",
"start": 2012.88,
"duration": 0.55
},
{
"text": "You're good.",
"start": 2013.43,
"duration": 0.5
},
{
"text": "6 and 1?",
"start": 2013.93,
"duration": 0.9
},
{
"text": "Let's fix that.",
"start": 2014.83,
"duration": 1.47
},
{
"text": "6 and 3?",
"start": 2016.3,
"duration": 0.82
},
{
"text": "Let's fix that.",
"start": 2017.12,
"duration": 1.59
},
{
"text": "6 and 7?",
"start": 2018.71,
"duration": 0.58
},
{
"text": "We're good.",
"start": 2019.29,
"duration": 0.5
},
{
"text": "7 and 5?",
"start": 2019.79,
"duration": 0.73
},
{
"text": "Let's fix that.",
"start": 2020.52,
"duration": 1.35
},
{
"text": "And now I can ignore number 8 because\nI know the end of my list is sorted.",
"start": 2021.87,
"duration": 3.65
},
{
"text": "So now, I've improved it slightly.",
"start": 2025.52,
"duration": 1.8
},
{
"text": "7 has bubbled up to\nwhere he needs to be.",
"start": 2027.32,
"duration": 2.06
},
{
"text": "I just have 6 problems\nleft to solve at most.",
"start": 2029.38,
"duration": 2.22
},
{
"text": "So now I look again.",
"start": 2031.6,
"duration": 0.88
},
{
"text": "2 and 4?",
"start": 2032.48,
"duration": 0.53
},
{
"text": "You're good.",
"start": 2033.01,
"duration": 0.77
},
{
"text": "1 and 4?",
"start": 2033.78,
"duration": 0.78
},
{
"text": "Let's swap that.",
"start": 2034.56,
"duration": 1.01
},
{
"text": "And notice, 1 is moving closer\nto the left of the list.",
"start": 2035.57,
"duration": 2.93
},
{
"text": "4 and 3?",
"start": 2038.5,
"duration": 0.51
},
{
"text": "Let's swap.",
"start": 2039.01,
"duration": 1.3
},
{
"text": "4 and 6?",
"start": 2040.31,
"duration": 0.6
},
{
"text": "You're good.",
"start": 2040.91,
"duration": 0.5
},
{
"text": "6 and 5?",
"start": 2041.41,
"duration": 0.61
},
{
"text": "You're not.",
"start": 2042.02,
"duration": 1.01
},
{
"text": "But now I fixed 6.",
"start": 2043.03,
"duration": 1.35
},
{
"text": "And I can stop here, leaving me\nwith just five potential problems.",
"start": 2044.38,
"duration": 3.042
},
{
"text": "And then you can see\nwhere this is going.",
"start": 2047.422,
"duration": 1.708
},
{
"text": "2 and 1?",
"start": 2049.13,
"duration": 0.5
},
{
"text": "Let's swap.",
"start": 2049.63,
"duration": 0.97
},
{
"text": "2 and 3?",
"start": 2050.6,
"duration": 0.5
},
{
"text": "You're good.",
"start": 2051.1,
"duration": 0.43
},
{
"text": "3 and 4?",
"start": 2051.53,
"duration": 0.55
},
{
"text": "You're good.",
"start": 2052.08,
"duration": 0.67
},
{
"text": "We already solved these problems.",
"start": 2052.75,
"duration": 1.42
},
{
"text": "So let me go back.",
"start": 2054.17,
"duration": 1.61
},
{
"text": "And now, 1 and 2?",
"start": 2055.78,
"duration": 1.22
},
{
"text": "You're good.",
"start": 2057.0,
"duration": 0.84
},
{
"text": "2 and 3?",
"start": 2057.84,
"duration": 0.54
},
{
"text": "You're good.",
"start": 2058.38,
"duration": 0.56
},
{
"text": "3 and 4, 4 and 5, 5 and\n6, 6 and 7, 7 and 8.",
"start": 2058.94,
"duration": 3.14
},
{
"text": "What do I know now as the computer?",
"start": 2062.08,
"duration": 3.61
},
{
"text": "What's that?",
"start": 2065.69,
"duration": 0.56
},
{
"text": "AUDIENCE: It's sorted.",
"start": 2066.25,
"duration": 0.31
},
{
"text": "SPEAKER 1: It's sorted.",
"start": 2066.56,
"duration": 0.958
},
{
"text": "Why?",
"start": 2067.518,
"duration": 0.911
},
{
"text": "AUDIENCE: Because everything's in order",
"start": 2068.429,
"duration": 1.901
},
{
"text": "SPEAKER 1: Everything is in order.",
"start": 2070.33,
"duration": 0.889
},
{
"text": "But what does that mean?",
"start": 2071.219,
"duration": 1.0
},
{
"text": "We humans can see that, but the computer\ncan only look at individual values",
"start": 2072.219,
"duration": 3.171
},
{
"text": "at a time.",
"start": 2075.39,
"duration": 0.499
},
{
"text": "It can't take a step back\nand say, yep, sorted.",
"start": 2075.889,
"duration": 2.966
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 2078.855,
"duration": 2.229
},
{
"text": "SPEAKER 1: Good.",
"start": 2081.084,
"duration": 0.666
},
{
"text": "At a lower level implementation\ndetail, I did no swaps.",
"start": 2081.75,
"duration": 3.46
},
{
"text": "There were no two numbers\nthat were out of order.",
"start": 2085.21,
"duration": 2.08
},
{
"text": "So it would just be\nfoolish of me and wasteful",
"start": 2087.29,
"duration": 3.31
},
{
"text": "for me to bother doing another pass.",
"start": 2090.6,
"duration": 1.78
},
{
"text": "Because assuming the numbers\nare not changing on their own,",
"start": 2092.38,
"duration": 2.67
},
{
"text": "I'm just going to do the same\nthing again and again otherwise.",
"start": 2095.05,
"duration": 2.583
},
{
"text": "So I can just stop.",
"start": 2097.633,
"duration": 1.227
},
{
"text": "And indeed, the bubble sort\nallows us to stop like this.",
"start": 2098.86,
"duration": 2.53
},
{
"text": "Let's do one last approach.",
"start": 2101.39,
"duration": 1.29
},
{
"text": "If you could, let me toss the\nstarting points on the board again.",
"start": 2102.68,
"duration": 4.04
},
{
"text": "Let's reset one last time to this.",
"start": 2106.72,
"duration": 3.589
},
{
"text": "And let me propose-- let me\ndraw inspiration, actually,",
"start": 2110.309,
"duration": 2.291
},
{
"text": "from the approach you took\nwith the blue books, which was",
"start": 2112.6,
"duration": 2.374
},
{
"text": "a little different from how we began.",
"start": 2114.974,
"duration": 1.706
},
{
"text": "Which was recall that you took\nthe problem on your left hand",
"start": 2116.68,
"duration": 3.572
},
{
"text": "and you just dealt\nwith it one at a time.",
"start": 2120.252,
"duration": 1.708
},
{
"text": "You didn't go sifting\nthrough looking for A.",
"start": 2121.96,
"duration": 1.83
},
{
"text": "You didn't go sifting\nthrough looking for B.",
"start": 2123.79,
"duration": 1.7
},
{
"text": "You didn't go sifting through\nlooking for C, which would really",
"start": 2125.49,
"duration": 2.11
},
{
"text": "be the analog of what you\nproposed a moment ago.",
"start": 2127.6,
"duration": 2.12
},
{
"text": "Instead, you just dealt with\neach problem as it came.",
"start": 2129.72,
"duration": 2.23
},
{
"text": "And this is our third\nand final algorithm",
"start": 2131.95,
"duration": 1.94
},
{
"text": "for sorting called insertion sort.",
"start": 2133.89,
"duration": 2.53
},
{
"text": "Take each problem one at a time and\njust deal with it then and there.",
"start": 2136.42,
"duration": 3.85
},
{
"text": "Don't postpone.",
"start": 2140.27,
"duration": 1.1
},
{
"text": "So here's 4.",
"start": 2141.37,
"duration": 0.923
},
{
"text": "You know what?",
"start": 2142.293,
"duration": 1.167
},
{
"text": "Done.",
"start": 2143.46,
"duration": 0.58
},
{
"text": "I now claim that this list, which\nwe'll visually make a little separate,",
"start": 2144.04,
"duration": 3.7
},
{
"text": "is sorted.",
"start": 2147.74,
"duration": 0.85
},
{
"text": "So I'm going to mentally divide my\nlist into a left half and a right half.",
"start": 2148.59,
"duration": 3.14
},
{
"text": "And now I just claim trivially-- I\nmean, almost silly-- this is sorted.",
"start": 2151.73,
"duration": 4.31
},
{
"text": "Because it is.",
"start": 2156.04,
"duration": 0.83
},
{
"text": "But now the right half\nof my list remains.",
"start": 2156.87,
"duration": 1.88
},
{
"text": "So let's go ahead and do this.",
"start": 2158.75,
"duration": 1.249
},
{
"text": "So number 2.",
"start": 2159.999,
"duration": 0.931
},
{
"text": "OK, where does this belong?",
"start": 2160.93,
"duration": 1.17
},
{
"text": "So if you want to go ahead\nand pick up the number.",
"start": 2162.1,
"duration": 2.083
},
{
"text": "The stand can stay.",
"start": 2164.183,
"duration": 1.297
},
{
"text": "Number 2 goes where?",
"start": 2165.48,
"duration": 1.79
},
{
"text": "Here's my left list.",
"start": 2167.27,
"duration": 1.045
},
{
"text": "And we'll make a little more\nspace here just to be clear.",
"start": 2168.315,
"duration": 2.375
},
{
"text": "It goes over to this side.",
"start": 2170.69,
"duration": 1.6
},
{
"text": "So what has to happen?",
"start": 2172.29,
"duration": 2.74
},
{
"text": "So this time, we do\nneed to shift you over.",
"start": 2175.03,
"duration": 2.84
},
{
"text": "So let's take 2 out.",
"start": 2177.87,
"duration": 1.37
},
{
"text": "Let's shift 4 over.",
"start": 2179.24,
"duration": 2.017
},
{
"text": "And now we won't move the stand.",
"start": 2181.257,
"duration": 1.333
},
{
"text": "We'll just assume now that\nmy left half is of size 2",
"start": 2182.59,
"duration": 3.25
},
{
"text": "and the right half is of size 6.",
"start": 2185.84,
"duration": 1.445
},
{
"text": "But now, the left half of\nthe list is still sorted,",
"start": 2187.285,
"duration": 2.125
},
{
"text": "but it costs me a little bit of work.",
"start": 2189.41,
"duration": 1.541
},
{
"text": "I had to move 4 over.",
"start": 2190.951,
"duration": 1.32
},
{
"text": "All right, let me deal with 6.",
"start": 2192.271,
"duration": 1.249
},
{
"text": "Where does 6 go?",
"start": 2193.52,
"duration": 1.684
},
{
"text": "It's already in order.",
"start": 2195.204,
"duration": 0.916
},
{
"text": "I don't need to shift anyone.",
"start": 2196.12,
"duration": 1.208
},
{
"text": "Where does 8 go?",
"start": 2197.328,
"duration": 0.792
},
{
"text": "Phew, it doesn't need to go anywhere.",
"start": 2198.12,
"duration": 1.541
},
{
"text": "It's already in order.",
"start": 2199.661,
"duration": 0.935
},
{
"text": "Uh-oh, 1.",
"start": 2200.596,
"duration": 0.774
},
{
"text": "Where does it go?",
"start": 2201.37,
"duration": 0.94
},
{
"text": "Now we incur a good amount of cost.",
"start": 2202.31,
"duration": 2.052
},
{
"text": "So let's do this.",
"start": 2204.362,
"duration": 0.708
},
{
"text": "Where do you go?",
"start": 2205.07,
"duration": 1.19
},
{
"text": "One shift, two shift,\nthree shifts, four shifts.",
"start": 2206.26,
"duration": 3.8
},
{
"text": "Feels-- yep-- as bad as\nour original approach.",
"start": 2210.06,
"duration": 3.49
},
{
"text": "But notice I only have\n4 more problems left.",
"start": 2213.55,
"duration": 1.979
},
{
"text": "I don't have to keep going\nback through the list.",
"start": 2215.529,
"duration": 2.041
},
{
"text": "So where does 3 go?",
"start": 2217.57,
"duration": 0.75
},
{
"text": "All right, let's pop you out.",
"start": 2218.32,
"duration": 1.208
},
{
"text": "Shift you in there.",
"start": 2219.528,
"duration": 1.862
},
{
"text": "7.",
"start": 2221.39,
"duration": 0.5
},
{
"text": "We got a little lucky.",
"start": 2221.89,
"duration": 0.916
},
{
"text": "Let's pop you out and insert\nyou right where you belong.",
"start": 2222.806,
"duration": 2.724
},
{
"text": "And then 5, you belong\na few shifts over.",
"start": 2225.53,
"duration": 2.8
},
{
"text": "So let's shift three of you.",
"start": 2228.33,
"duration": 2.4
},
{
"text": "And then, done.",
"start": 2230.73,
"duration": 1.6
},
{
"text": "All right.",
"start": 2232.33,
"duration": 0.5
},
{
"text": "So let's give all of you a stress ball.",
"start": 2232.83,
"duration": 1.72
},
{
"text": "And maybe a round of applause.",
"start": 2234.55,
"duration": 1.249
},
{
"text": "And let's see if we can't tease\napart what just happened here.",
"start": 2235.799,
"duration": 3.261
},
{
"text": "All right.",
"start": 2239.06,
"duration": 1.59
},
{
"text": "And then you can exit stage\nleft-- right if you'd like.",
"start": 2240.65,
"duration": 3.255
},
{
"text": "All right, thank you.",
"start": 2243.905,
"duration": 0.875
},
{
"text": "Derek, you're really\nracking them up here.",
"start": 2244.78,
"duration": 1.435
},
{
"text": "All right.",
"start": 2246.215,
"duration": 0.275
},
{
"text": "AUDIENCE: I'll [INAUDIBLE].",
"start": 2246.49,
"duration": 0.96
},
{
"text": "SPEAKER 1: All right.",
"start": 2247.45,
"duration": 0.875
},
{
"text": "Thank you.",
"start": 2248.325,
"duration": 0.745
},
{
"text": "All right.",
"start": 2249.07,
"duration": 0.771
},
{
"text": "Sure.",
"start": 2249.841,
"duration": 0.499
},
{
"text": "So what was the point of this exercise?",
"start": 2250.34,
"duration": 1.624
},
{
"text": "And how do we actually now get to\na decision point where one of these",
"start": 2251.964,
"duration": 3.806
},
{
"text": "is the way to go?",
"start": 2255.77,
"duration": 1.89
},
{
"text": "So in bubble sort, recall that\nthe key was to do something",
"start": 2257.66,
"duration": 2.59
},
{
"text": "again and again until we did no swaps.",
"start": 2260.25,
"duration": 2.494
},
{
"text": "At which point we could conclude\nthat the list was sorted.",
"start": 2262.744,
"duration": 2.416
},
{
"text": "So let's do exactly that,\nrepeat until no swaps.",
"start": 2265.16,
"duration": 2.692
},
{
"text": "And then, let's give\nourselves a counter,",
"start": 2267.852,
"duration": 1.708
},
{
"text": "just to make things a\nlittle more methodical,",
"start": 2269.56,
"duration": 1.874
},
{
"text": "and say for i from 0 to n\nminus 1-- rather n minus 2.",
"start": 2271.434,
"duration": 4.946
},
{
"text": "Why?",
"start": 2276.38,
"duration": 0.68
},
{
"text": "Well, the end of the list\nrecall is it n minus 1.",
"start": 2277.06,
"duration": 3.11
},
{
"text": "Because if you have a list of\nsize n, the beginning is at 0.",
"start": 2280.17,
"duration": 3.12
},
{
"text": "The end is at n minus 1.",
"start": 2283.29,
"duration": 1.95
},
{
"text": "And so one shy of the end\nis going to be n minus 2.",
"start": 2285.24,
"duration": 3.25
},
{
"text": "So we want to do this up through\nthe second to last element.",
"start": 2288.49,
"duration": 3.42
},
{
"text": "If the i-th and the i-th plus\n1 elements are out of order.",
"start": 2291.91,
"duration": 4.87
},
{
"text": "So if left hand and right hand\nare out of order, swap them.",
"start": 2296.78,
"duration": 3.62
},
{
"text": "And repeat this again\nand again and again.",
"start": 2300.4,
"duration": 1.8
},
{
"text": "And thanks to that\nouter loop, we're going",
"start": 2302.2,
"duration": 1.75
},
{
"text": "to do it again and again and\nagain until we have no such swaps.",
"start": 2303.95,
"duration": 4.04
},
{
"text": "And now to be clear, why this n minus 2?",
"start": 2307.99,
"duration": 2.31
},
{
"text": "We want to make sure as we're sort\nof walking down our row of volunteers",
"start": 2310.3,
"duration": 3.21
},
{
"text": "that my left hand does not actually\npoint at the last human on stage",
"start": 2313.51,
"duration": 4.1
},
{
"text": "because then, where would\nmy right hand point?",
"start": 2317.61,
"duration": 2.04
},
{
"text": "There's no person to beyond that point.",
"start": 2319.65,
"duration": 3.264
},
{
"text": "So this then is bubble sort.",
"start": 2322.914,
"duration": 1.166
},
{
"text": "Now, let's propose pseudocode for\nour other algorithm, selection sort,",
"start": 2324.08,
"duration": 4.23
},
{
"text": "wherein we walked through\nthe list iteratively",
"start": 2328.31,
"duration": 2.44
},
{
"text": "trying to select on each\npass the smallest element",
"start": 2330.75,
"duration": 3.28
},
{
"text": "and putting it into its place.",
"start": 2334.03,
"duration": 1.51
},
{
"text": "So for i from 0 to n\nminus 1, we're going",
"start": 2335.54,
"duration": 2.77
},
{
"text": "to do this from beginning\nthrough the end,",
"start": 2338.31,
"duration": 2.13
},
{
"text": "find the smallest element between\ni-th and n-th minus 1 element.",
"start": 2340.44,
"duration": 4.69
},
{
"text": "Swap the smallest with\nthat i-th element.",
"start": 2345.13,
"duration": 3.68
},
{
"text": "In other words, walk through the list.",
"start": 2348.81,
"duration": 1.78
},
{
"text": "Find the smallest, put it on the end.",
"start": 2350.59,
"duration": 1.62
},
{
"text": "Walk through the list, swap\nit with the second to the end.",
"start": 2352.21,
"duration": 3.58
},
{
"text": "Walk through the list, do the\nsame, do the same, do the same,",
"start": 2355.79,
"duration": 2.74
},
{
"text": "each time grabbing the\nthen smallest element.",
"start": 2358.53,
"duration": 2.87
},
{
"text": "And then lastly, we had insertion sort,\nwhereby we iterated through the list,",
"start": 2361.4,
"duration": 5.0
},
{
"text": "but we pretty much dealt with\nevery element as we encountered it.",
"start": 2366.4,
"duration": 3.057
},
{
"text": "So let me propose this\npseudocode code here.",
"start": 2369.457,
"duration": 1.833
},
{
"text": "For i from 1 to n minus 1.",
"start": 2371.29,
"duration": 3.087
},
{
"text": "So let's just assume that the\nvery beginning of the list",
"start": 2374.377,
"duration": 2.333
},
{
"text": "is sort of trivially sorted, no\nmatter what number he or she is.",
"start": 2376.71,
"duration": 3.35
},
{
"text": "Because if that left side of the list\nis of size 1, it is, indeed, sorted.",
"start": 2380.06,
"duration": 4.09
},
{
"text": "And indeed, let's call the 0-th element\nthrough the i minus [? 1-th ?] element,",
"start": 2384.15,
"duration": 4.57
},
{
"text": "wherever we are, the sorted side.",
"start": 2388.72,
"duration": 2.26
},
{
"text": "So essentially, call the\nleft the sorted side.",
"start": 2390.98,
"duration": 1.93
},
{
"text": "And you can think of the right-hand\nside as the unsorted side.",
"start": 2392.91,
"duration": 2.75
},
{
"text": "Remove the i-th element, whatever\nelement you're dealing with,",
"start": 2395.66,
"duration": 3.53
},
{
"text": "and insert it into the\nsorted side in order.",
"start": 2399.19,
"duration": 3.56
},
{
"text": "In other words, just walk\nthrough the list, one at a time,",
"start": 2402.75,
"duration": 2.79
},
{
"text": "plucking out elements, and\nthen forcibly insert them",
"start": 2405.54,
"duration": 2.78
},
{
"text": "into the sorted side of\nthe list, making room,",
"start": 2408.32,
"duration": 2.65
},
{
"text": "as our humans did, for that\nlist by shuffling everyone over.",
"start": 2410.97,
"duration": 4.21
},
{
"text": "This then was bubble sort,\nselection sort, and insertion sort.",
"start": 2415.18,
"duration": 5.12
},
{
"text": "But which to choose?",
"start": 2420.3,
"duration": 1.86
},
{
"text": "So let's introduce now an answer to why.",
"start": 2422.16,
"duration": 2.929
},
{
"text": "Not just what these things are, but\nwhy you might use one over the other.",
"start": 2425.089,
"duration": 3.041
},
{
"text": "So the running time\nof an algorithm might",
"start": 2428.13,
"duration": 2.22
},
{
"text": "be the number of seconds\nan algorithm takes to run,",
"start": 2430.35,
"duration": 2.26
},
{
"text": "or the number of minutes, or the number\nof steps, or the number of comparisons.",
"start": 2432.61,
"duration": 3.06
},
{
"text": "It doesn't really matter\nwhat your unit of measure",
"start": 2435.67,
"duration": 1.78
},
{
"text": "is, so long as you're consistent,\nwhatever feels the most",
"start": 2437.45,
"duration": 2.374
},
{
"text": "expensive or useful to express.",
"start": 2439.824,
"duration": 2.346
},
{
"text": "So let's consider an\nexample, like bubble sort.",
"start": 2442.17,
"duration": 2.62
},
{
"text": "If we want to consider the\nefficiency of bubble sort",
"start": 2444.79,
"duration": 3.432
},
{
"text": "and make a claim as to\nwhether we should or shouldn't",
"start": 2448.222,
"duration": 2.208
},
{
"text": "use it because it's good or bad, let's\nconsider it a little formulaically.",
"start": 2450.43,
"duration": 3.56
},
{
"text": "So a little mathy, but\npretty generically.",
"start": 2453.99,
"duration": 2.37
},
{
"text": "So if there are n elements to\nstore, and a computer scientist,",
"start": 2456.36,
"duration": 3.72
},
{
"text": "recall from week 0, will generally just\ncall n the size of his or her problem.",
"start": 2460.08,
"duration": 3.78
},
{
"text": "n is the number of numbers\nto sort, or humans to sort.",
"start": 2463.86,
"duration": 3.52
},
{
"text": "How many steps is it going to\ntake to sort that many people?",
"start": 2467.38,
"duration": 4.81
},
{
"text": "Well, when I had 8 music stands\nand 8 people here before,",
"start": 2472.19,
"duration": 3.63
},
{
"text": "I considered a pair, a pair,\na pair, a pair, a pair.",
"start": 2475.82,
"duration": 4.737
},
{
"text": "And so if there were n humans up here.",
"start": 2480.557,
"duration": 1.583
},
{
"text": "Or let's speak concretely,\n8 people initially.",
"start": 2482.14,
"duration": 2.53
},
{
"text": "How many pairs of people did\nI consider in my first pass?",
"start": 2484.67,
"duration": 4.321
},
{
"text": "Say again.",
"start": 2488.991,
"duration": 0.499
},
{
"text": "AUDIENCE: 7.",
"start": 2489.49,
"duration": 0.499
},
{
"text": "SPEAKER 1: 7.",
"start": 2489.989,
"duration": 0.921
},
{
"text": "Because if you pair the\nfirst and the second,",
"start": 2490.91,
"duration": 2.019
},
{
"text": "then the second and the third,\nthen the third and the fourth,",
"start": 2492.929,
"duration": 2.541
},
{
"text": "that gives you n minus\n1 generally speaking.",
"start": 2495.47,
"duration": 2.13
},
{
"text": "You can't make 8 pairs out of 8 people.",
"start": 2497.6,
"duration": 1.65
},
{
"text": "You can make 7 pairs if you\nkeep walking through the list.",
"start": 2499.25,
"duration": 2.542
},
{
"text": "We're not doing permutations.",
"start": 2501.792,
"duration": 1.208
},
{
"text": "We're just doing adjacent neighbors.",
"start": 2503.0,
"duration": 2.25
},
{
"text": "OK.",
"start": 2505.25,
"duration": 0.5
},
{
"text": "So that might generically\nbe n minus 1 total steps",
"start": 2505.75,
"duration": 3.3
},
{
"text": "for the first pass of my algorithm.",
"start": 2509.05,
"duration": 1.72
},
{
"text": "But the upside of that was that\nour eighth volunteer, number 8,",
"start": 2510.77,
"duration": 3.39
},
{
"text": "bubbled his way all\nthe way up to the end.",
"start": 2514.16,
"duration": 2.95
},
{
"text": "And so with bubble sort, I didn't\nneed to consider him again.",
"start": 2517.11,
"duration": 3.01
},
{
"text": "The biggest number\nbubbled all the way up.",
"start": 2520.12,
"duration": 2.3
},
{
"text": "And so that was done.",
"start": 2522.42,
"duration": 1.14
},
{
"text": "So how many pairs did I need to consider\nthe second time through bubble sort?",
"start": 2523.56,
"duration": 6.03
},
{
"text": "6.",
"start": 2529.59,
"duration": 0.5
},
{
"text": "Or more generically, n minus 2.",
"start": 2530.09,
"duration": 3.68
},
{
"text": "And then dot, dot, dot, until there\nwas just one pair of two people left.",
"start": 2533.77,
"duration": 4.41
},
{
"text": "So I'll just do plus\ndot, dot, dot plus 1.",
"start": 2538.18,
"duration": 2.727
},
{
"text": "Now, you might recall from\nhigh school especially,",
"start": 2540.907,
"duration": 2.083
},
{
"text": "at least my math or\nphysics textbooks always",
"start": 2542.99,
"duration": 1.833
},
{
"text": "had a little cheat sheet for like what\nthese kinds of recurrences or formulas",
"start": 2544.823,
"duration": 3.277
},
{
"text": "add up to.",
"start": 2548.1,
"duration": 0.5
},
{
"text": "Does anyone recall what this\none adds up to in a math book?",
"start": 2548.6,
"duration": 3.96
},
{
"text": "Or just mathematically?",
"start": 2552.56,
"duration": 3.27
},
{
"text": "So if we actually do this out,\nit's the same thing, beautifully,",
"start": 2555.83,
"duration": 3.57
},
{
"text": "as n times n minus 1 over 2.",
"start": 2559.4,
"duration": 3.25
},
{
"text": "And that, of course if\nyou multiply things out,",
"start": 2562.65,
"duration": 3.63
},
{
"text": "is just the same thing as\nn squared minus n over 2.",
"start": 2566.28,
"duration": 3.26
},
{
"text": "And that, of course, feels like it\nwould just multiply out to this.",
"start": 2569.54,
"duration": 6.35
},
{
"text": "So in other words, if asked, what\nis the efficiency of bubble sort,",
"start": 2575.89,
"duration": 2.97
},
{
"text": "or what is the running time of\nbubble sort to soar n elements,",
"start": 2578.86,
"duration": 3.47
},
{
"text": "you might sort of\nimpressively say, well, it's",
"start": 2582.33,
"duration": 1.94
},
{
"text": "n squared divided by 2 minus n over 2.",
"start": 2584.27,
"duration": 2.37
},
{
"text": "But what does that actually mean?",
"start": 2586.64,
"duration": 1.51
},
{
"text": "Well, it turns out that when talking\nabout the efficiency of algorithms,",
"start": 2588.15,
"duration": 3.42
},
{
"text": "you should really generally\ncare about the component that",
"start": 2591.57,
"duration": 3.4
},
{
"text": "has the biggest order of magnitude.",
"start": 2594.97,
"duration": 2.07
},
{
"text": "The number that contributes\nthe most to the total cost.",
"start": 2597.04,
"duration": 2.94
},
{
"text": "And by that I mean this, which is\nobviously bigger, n squared or n?",
"start": 2599.98,
"duration": 4.04
},
{
"text": "Assuming positive values of n.",
"start": 2604.02,
"duration": 1.68
},
{
"text": "So n squared, right?",
"start": 2605.7,
"duration": 1.13
},
{
"text": "Especially as n gets bigger, n squared\nis going to get even bigger than n.",
"start": 2606.83,
"duration": 3.692
},
{
"text": "So you know what?",
"start": 2610.522,
"duration": 0.708
},
{
"text": "I'm just going to kind of propose,\nlet's just ignore the n minus 2",
"start": 2611.23,
"duration": 3.77
},
{
"text": "because as n gets really big,\nthe dominating factor really",
"start": 2615.0,
"duration": 2.69
},
{
"text": "is going to be n square.",
"start": 2617.69,
"duration": 1.24
},
{
"text": "And for that matter, the n over 2,\nlike who cares about the over 2?",
"start": 2618.93,
"duration": 2.82
},
{
"text": "n squared is kind of the essence\nof this formula right now.",
"start": 2621.75,
"duration": 3.672
},
{
"text": "So what does that mean?",
"start": 2625.422,
"duration": 0.958
},
{
"text": "Well, let's just do a concrete\nexample to convince you of the fact",
"start": 2626.38,
"duration": 2.749
},
{
"text": "that we can cut a little bit\nof mathematical corner here",
"start": 2629.129,
"duration": 2.911
},
{
"text": "and only care about the big\nnumber for the following example.",
"start": 2632.04,
"duration": 2.792
},
{
"text": "This is proof by example, which\nis not a proof of anything.",
"start": 2634.832,
"duration": 2.458
},
{
"text": "It's just really to paint a picture\nof why we do this intuitively.",
"start": 2637.29,
"duration": 4.03
},
{
"text": "So suppose that there are a million\nvolunteers on stage or a million",
"start": 2641.32,
"duration": 2.892
},
{
"text": "numbers that we want to sort.",
"start": 2644.212,
"duration": 1.208
},
{
"text": "Much bigger than 8.",
"start": 2645.42,
"duration": 1.55
},
{
"text": "Let's plug this in.",
"start": 2646.97,
"duration": 1.15
},
{
"text": "So if the total cost of bubble sort\nis n squared over 2 minus n over 2,",
"start": 2648.12,
"duration": 3.83
},
{
"text": "let's plug that in.",
"start": 2651.95,
"duration": 0.85
},
{
"text": "So that's a million squared divided\nby 2 minus a million divided by 2.",
"start": 2652.8,
"duration": 4.75
},
{
"text": "So if we multiply that out, that\nis 500 billion minus 500,000.",
"start": 2657.55,
"duration": 5.39
},
{
"text": "Big numbers.",
"start": 2662.94,
"duration": 0.86
},
{
"text": "But when you multiply that out,\nI mean-- my god, 499,999,500,000.",
"start": 2663.8,
"duration": 5.25
},
{
"text": "I mean, to my own eyes, that's\npretty darn close to 500 billion",
"start": 2669.05,
"duration": 5.24
},
{
"text": "in the first place.",
"start": 2674.29,
"duration": 0.797
},
{
"text": "Why don't we just call it 500 billion?",
"start": 2675.087,
"duration": 1.583
},
{
"text": "So n squared, in other words.",
"start": 2676.67,
"duration": 1.489
},
{
"text": "So again, this is not a\nformal proof of anything.",
"start": 2678.159,
"duration": 2.041
},
{
"text": "But this is why, especially\nas n gets bigger,",
"start": 2680.2,
"duration": 2.25
},
{
"text": "that lower-ordered term,\nthe minus n over 2,",
"start": 2682.45,
"duration": 2.53
},
{
"text": "just matters less and less\nand less in absolute form.",
"start": 2684.98,
"duration": 3.37
},
{
"text": "And so we'll generally say that\nsomething like bubble sort,",
"start": 2688.35,
"duration": 2.98
},
{
"text": "its running time is on\nthe order of n squared.",
"start": 2691.33,
"duration": 3.6
},
{
"text": "Big O is actually formal computer\nscience notation for on the order of.",
"start": 2694.93,
"duration": 4.097
},
{
"text": "And it has a formal\nmathematical definition.",
"start": 2699.027,
"duration": 1.833
},
{
"text": "But for us, we'll consider it really\nto be an upper bound on the running",
"start": 2700.86,
"duration": 5.57
},
{
"text": "time of this algorithm.",
"start": 2706.43,
"duration": 1.38
},
{
"text": "So an upper bound on how long this\nalgorithm might take given n steps.",
"start": 2707.81,
"duration": 4.29
},
{
"text": "So big O itself is a formal notation.",
"start": 2712.1,
"duration": 2.14
},
{
"text": "We'll see it in a number\nof different contexts.",
"start": 2714.24,
"duration": 2.04
},
{
"text": "Depending on the algorithms\nwe talk about in class,",
"start": 2716.28,
"duration": 2.31
},
{
"text": "we might say that the\nrunning time of an algorithm",
"start": 2718.59,
"duration": 2.083
},
{
"text": "is on the order of n\nsquared, which is pretty bad.",
"start": 2720.673,
"duration": 2.687
},
{
"text": "Pretty slow. $500 billion\nsounds like a lot.",
"start": 2723.36,
"duration": 2.21
},
{
"text": "Well, maybe it's a little better\non the order of n times log n.",
"start": 2725.57,
"duration": 2.625
},
{
"text": "And more on that some\nother time-- later.",
"start": 2728.195,
"duration": 2.955
},
{
"text": "But on the order of\nn, it was pretty good.",
"start": 2731.15,
"duration": 2.5
},
{
"text": "If there's n elements, it only\ntakes you roughly n steps.",
"start": 2733.65,
"duration": 2.54
},
{
"text": "Maybe it's even better big O of log n.",
"start": 2736.19,
"duration": 2.88
},
{
"text": "Or really best would be big O of 1.",
"start": 2739.07,
"duration": 2.565
},
{
"text": "It just takes 1 step, or\n10 steps, or 100 steps,",
"start": 2741.635,
"duration": 2.595
},
{
"text": "but a constant number of steps\nis what big O of 1 represents.",
"start": 2744.23,
"duration": 4.05
},
{
"text": "And there's any number\nof other formulas we",
"start": 2748.28,
"duration": 2.2
},
{
"text": "could use or equations to express\nthe running time of algorithms.",
"start": 2750.48,
"duration": 3.89
},
{
"text": "But many of the algorithms\nwe'll look at in CS50 certainly",
"start": 2754.37,
"duration": 2.47
},
{
"text": "fall into these categories.",
"start": 2756.84,
"duration": 1.67
},
{
"text": "So let's take an example.",
"start": 2758.51,
"duration": 2.89
},
{
"text": "What algorithm has the running\ntime of big O of n squared?",
"start": 2761.4,
"duration": 2.73
},
{
"text": "Well, bubble sort for one thing.",
"start": 2764.13,
"duration": 3.02
},
{
"text": "And it turns out selection sort.",
"start": 2767.15,
"duration": 2.12
},
{
"text": "And it turns out insertion sort.",
"start": 2769.27,
"duration": 2.84
},
{
"text": "All three of those algorithms\nactually have the same running time,",
"start": 2772.11,
"duration": 3.81
},
{
"text": "even though they're fundamentally\ndifferent in execution.",
"start": 2775.92,
"duration": 3.44
},
{
"text": "But they do share a commonality.",
"start": 2779.36,
"duration": 2.01
},
{
"text": "All of them are comparison-based.",
"start": 2781.37,
"duration": 2.72
},
{
"text": "In each case did we\nactually compare values,",
"start": 2784.09,
"duration": 2.31
},
{
"text": "either adjacent or we would look at a\nnumber there, compare it to a number",
"start": 2786.4,
"duration": 3.33
},
{
"text": "here, and then decide whether\nor not to do a switch.",
"start": 2789.73,
"duration": 2.234
},
{
"text": "So they were all comparison-based.",
"start": 2791.964,
"duration": 1.416
},
{
"text": "And all of them, frankly, involved\nquite a bit of movement or walking,",
"start": 2793.38,
"duration": 3.24
},
{
"text": "either on my part or the\nhumans-- volunteers part.",
"start": 2796.62,
"duration": 2.48
},
{
"text": "For instance, in bubble\nsort's case, I had",
"start": 2799.1,
"duration": 2.64
},
{
"text": "to walk through the whole list,\nsorting elements pairwise like this.",
"start": 2801.74,
"duration": 3.425
},
{
"text": "But that wasn't enough.",
"start": 2805.165,
"duration": 1.575
},
{
"text": "I then had to do it again\nand walk across the stage.",
"start": 2806.74,
"duration": 4.14
},
{
"text": "And then I had to do it again\nand walk across the stage.",
"start": 2810.88,
"duration": 2.78
},
{
"text": "And this is what n squared feels like.",
"start": 2813.66,
"duration": 1.627
},
{
"text": "And even though the problem\nwas getting a little smaller",
"start": 2815.287,
"duration": 2.333
},
{
"text": "as the big elements bubbled up,\nmathematically, even that algorithm,",
"start": 2817.62,
"duration": 4.32
},
{
"text": "it's kind of essentially like doing\nn things, looking at n people,",
"start": 2821.94,
"duration": 3.76
},
{
"text": "n times, iterating n total times, which\nis roughly n times n, or n squared.",
"start": 2825.7,
"duration": 4.517
},
{
"text": "It's just going to add up a lot.",
"start": 2830.217,
"duration": 1.333
},
{
"text": "So what about selection sort?",
"start": 2831.55,
"duration": 1.61
},
{
"text": "What did I do in selection sort's case?",
"start": 2833.16,
"duration": 1.65
},
{
"text": "Here, it's even more obvious, perhaps.",
"start": 2834.81,
"duration": 1.8
},
{
"text": "To find the smallest\nelement in a list, I",
"start": 2836.61,
"duration": 2.2
},
{
"text": "have to look logically at every element\nbefore I can confidently conclude,",
"start": 2838.81,
"duration": 5.105
},
{
"text": "yes, I have found the smallest element.",
"start": 2843.915,
"duration": 1.625
},
{
"text": "Once you find it, you can\nplop it at the beginning.",
"start": 2845.54,
"duration": 2.125
},
{
"text": "And that's easy.",
"start": 2847.665,
"duration": 0.785
},
{
"text": "But then you have to find\nthe second smallest element.",
"start": 2848.45,
"duration": 1.95
},
{
"text": "And even though we humans could\nkind of eyeball things and realize,",
"start": 2850.4,
"duration": 2.791
},
{
"text": "oh, 2 is the next smallest.",
"start": 2853.191,
"duration": 1.249
},
{
"text": "You don't know that as the computer\nunless you look at every element.",
"start": 2854.44,
"duration": 2.91
},
{
"text": "Ah, I found 2.",
"start": 2857.35,
"duration": 1.49
},
{
"text": "And then you could put\n2 where it belongs.",
"start": 2858.84,
"duration": 1.75
},
{
"text": "So again, there's this\nwalking back and forth.",
"start": 2860.59,
"duration": 2.18
},
{
"text": "And if you're going to walk as many as\nn steps and have to do this n times--",
"start": 2862.77,
"duration": 3.9
},
{
"text": "one for every element--\nthat, too, is n times n.",
"start": 2866.67,
"duration": 2.13
},
{
"text": "And insertion sort, same damn\nproblem, even though it's",
"start": 2868.8,
"duration": 2.9
},
{
"text": "sort of logically\ndifferent, the algorithm.",
"start": 2871.7,
"duration": 1.91
},
{
"text": "Insertion sort, beautifully I\nonly move one step at a time",
"start": 2873.61,
"duration": 4.51
},
{
"text": "and I never turn back.",
"start": 2878.12,
"duration": 1.14
},
{
"text": "Because I just deal with, as you did\nfor the blue books, each problem one",
"start": 2879.26,
"duration": 5.24
},
{
"text": "at a time, never again backtracking.",
"start": 2884.5,
"duration": 2.36
},
{
"text": "But where was all the work happening?",
"start": 2886.86,
"duration": 3.34
},
{
"text": "In the shifting of humans.",
"start": 2890.2,
"duration": 1.44
},
{
"text": "Now, technically you guys helped out\nby doing the shifting yourselves.",
"start": 2891.64,
"duration": 2.92
},
{
"text": "But if I'm the computer,\nit actually would",
"start": 2894.56,
"duration": 1.749
},
{
"text": "have been like me tiptoeing back,\nshifting, shifting, shifting,",
"start": 2896.309,
"duration": 3.391
},
{
"text": "inserting, shifting, shifting, shifting.",
"start": 2899.7,
"duration": 2.18
},
{
"text": "So again, in the worst\ncase, I might have",
"start": 2901.88,
"duration": 1.71
},
{
"text": "had to shift everyone all the way\nover to make room for someone.",
"start": 2903.59,
"duration": 3.94
},
{
"text": "Because in the worst case,\nwhat's the worst possible input",
"start": 2907.53,
"duration": 2.55
},
{
"text": "you might get to a sorting algorithm?",
"start": 2910.08,
"duration": 3.4
},
{
"text": "What input would create\nthe most work for you?",
"start": 2913.48,
"duration": 3.805
},
{
"text": "AUDIENCE: Backwards.",
"start": 2917.285,
"duration": 0.86
},
{
"text": "SPEAKER 1: Backwards.",
"start": 2918.145,
"duration": 0.875
},
{
"text": "If the list is perfectly\nbackwards, every darn element",
"start": 2919.02,
"duration": 2.69
},
{
"text": "is out of place, which means you\nhave to traipse back and forth",
"start": 2921.71,
"duration": 3.14
},
{
"text": "and back and forth to insert or to\nselect or to swap all of those elements",
"start": 2924.85,
"duration": 5.85
},
{
"text": "that many times.",
"start": 2930.7,
"duration": 1.1
},
{
"text": "So in all of these cases, they\nare not numerically identical.",
"start": 2931.8,
"duration": 3.53
},
{
"text": "Some of those algorithms might take\nfewer steps than others in totality,",
"start": 2935.33,
"duration": 3.97
},
{
"text": "but they're all on the order\nof n squared for the reason",
"start": 2939.3,
"duration": 2.86
},
{
"text": "that they're all involving comparisons\nas many as n times n times.",
"start": 2942.16,
"duration": 4.79
},
{
"text": "All right.",
"start": 2946.95,
"duration": 0.68
},
{
"text": "What about an algorithm\nthat's big O of n?",
"start": 2947.63,
"duration": 3.2
},
{
"text": "An algorithm that only takes n steps?",
"start": 2950.83,
"duration": 3.65
},
{
"text": "We've seen one.",
"start": 2954.48,
"duration": 0.878
},
{
"text": "Derek showed us one.",
"start": 2958.05,
"duration": 1.26
},
{
"text": "What's an algorithm that takes n steps?",
"start": 2962.45,
"duration": 1.68
},
{
"text": "Derek, hopefully.",
"start": 2964.13,
"duration": 1.094
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 2965.224,
"duration": 0.916
},
{
"text": "SPEAKER 1: A random search?",
"start": 2966.14,
"duration": 1.49
},
{
"text": "Kind of, sort of.",
"start": 2967.63,
"duration": 1.07
},
{
"text": "It's a little harder to\nput a number to because it",
"start": 2968.7,
"duration": 3.244
},
{
"text": "depends what you mean by \"random.\"",
"start": 2971.944,
"duration": 1.416
},
{
"text": "Because if you have random\nwith repetition such",
"start": 2973.36,
"duration": 2.11
},
{
"text": "that you're checking foolishly\nthe same elements again and again,",
"start": 2975.47,
"duration": 2.877
},
{
"text": "it can actually add up\nto more than n steps.",
"start": 2978.347,
"duration": 1.833
},
{
"text": "So not random, but-- yeah.",
"start": 2980.18,
"duration": 2.805
},
{
"text": "AUDIENCE: Binary.",
"start": 2982.985,
"duration": 0.8
},
{
"text": "SPEAKER 1: Binary is even better.",
"start": 2983.785,
"duration": 1.375
},
{
"text": "Hold that answer.",
"start": 2985.16,
"duration": 0.708
},
{
"text": "You're about to be correct.",
"start": 2985.868,
"duration": 2.012
},
{
"text": "Linear search, right?",
"start": 2987.88,
"duration": 1.0
},
{
"text": "If you just blindly\ngo from left to right",
"start": 2988.88,
"duration": 1.88
},
{
"text": "or right to left looking\nfor some element,",
"start": 2990.76,
"duration": 1.81
},
{
"text": "that is on the order of n steps.",
"start": 2992.57,
"duration": 1.49
},
{
"text": "Because you are just doing\nfoolishly unnecessary",
"start": 2994.06,
"duration": 2.61
},
{
"text": "work if you go beyond\nthe end of the list",
"start": 2996.67,
"duration": 2.2
},
{
"text": "or beyond the beginning of the list.",
"start": 2998.87,
"duration": 1.5
},
{
"text": "You only need n steps for linear search.",
"start": 3000.37,
"duration": 2.07
},
{
"text": "But what if you want to instead find\nan algorithm that's logarithmic?",
"start": 3002.44,
"duration": 4.72
},
{
"text": "What algorithm that we used\nmight be logarithmic in nature?",
"start": 3007.16,
"duration": 5.03
},
{
"text": "Binary.",
"start": 3012.19,
"duration": 0.62
},
{
"text": "So binary search, as Derek proposed,\nonce we knew the list was sorted",
"start": 3012.81,
"duration": 4.54
},
{
"text": "was an alternative to that.",
"start": 3017.35,
"duration": 2.32
},
{
"text": "And constant time.",
"start": 3019.67,
"duration": 0.94
},
{
"text": "What about this?",
"start": 3020.61,
"duration": 2.46
},
{
"text": "What's an algorithm, maybe\nindependent of today,",
"start": 3023.07,
"duration": 2.0
},
{
"text": "that allows you constant\ntime, running time?",
"start": 3025.07,
"duration": 2.63
},
{
"text": "It could be anything.",
"start": 3034.986,
"duration": 0.874
},
{
"text": "How about hello world?",
"start": 3035.86,
"duration": 2.79
},
{
"text": "The [? say ?] block,\nor printf like that.",
"start": 3038.65,
"duration": 1.95
},
{
"text": "If you can just say a\nwhole phrase at once.",
"start": 3040.6,
"duration": 2.15
},
{
"text": "Or maybe just adding two numbers\ntogether is like one step.",
"start": 3042.75,
"duration": 3.57
},
{
"text": "No matter how big the numbers\nare, it still just takes one step",
"start": 3046.32,
"duration": 2.674
},
{
"text": "to add them all together.",
"start": 3048.994,
"duration": 1.041
},
{
"text": "It depends on some of the\nlower-level implementation details.",
"start": 3050.035,
"duration": 2.365
},
{
"text": "And even printf or the [? say ?]\nblock has multiple characters.",
"start": 3052.4,
"duration": 2.56
},
{
"text": "So we'll actually come\nback to this in the future",
"start": 3054.96,
"duration": 2.041
},
{
"text": "as to what it really means to be a step.",
"start": 3057.001,
"duration": 1.819
},
{
"text": "But anything that takes a\nconstant number of steps.",
"start": 3058.82,
"duration": 2.95
},
{
"text": "Checking an \"if\" condition,\nreturning a value.",
"start": 3061.77,
"duration": 2.4
},
{
"text": "Statements, generally, might be\nbroadly speaking just constant time,",
"start": 3064.17,
"duration": 3.24
},
{
"text": "but we'll see contradictions\nto that before long.",
"start": 3067.41,
"duration": 2.82
},
{
"text": "So let's take a look\nat two other symbols.",
"start": 3070.23,
"duration": 2.02
},
{
"text": "This one being a capital omega symbol.",
"start": 3072.25,
"duration": 2.56
},
{
"text": "And this omega symbol is the\nopposite, really, of big O. Big O",
"start": 3074.81,
"duration": 3.64
},
{
"text": "is an upper bound on the running time.",
"start": 3078.45,
"duration": 1.61
},
{
"text": "In the worst case, how\nmany steps might it",
"start": 3080.06,
"duration": 1.75
},
{
"text": "take to find an element\nin a list of n elements?",
"start": 3081.81,
"duration": 2.97
},
{
"text": "n steps.",
"start": 3084.78,
"duration": 1.05
},
{
"text": "So big O of n.",
"start": 3085.83,
"duration": 1.137
},
{
"text": "Bubble sort, selection\nsort, insertion sort?",
"start": 3086.967,
"duration": 1.833
},
{
"text": "They're on the order of n squared.",
"start": 3088.8,
"duration": 1.69
},
{
"text": "But what about the lower bound?",
"start": 3090.49,
"duration": 1.78
},
{
"text": "Especially when you get lucky\nin the best case so to speak,",
"start": 3092.27,
"duration": 2.9
},
{
"text": "how few steps might you\nsolve problems with?",
"start": 3095.17,
"duration": 2.58
},
{
"text": "So for instance, if we\nconsider the same formulas,",
"start": 3097.75,
"duration": 2.78
},
{
"text": "but this time with capital\nomega, what's an algorithm",
"start": 3100.53,
"duration": 3.22
},
{
"text": "that no matter what\ntakes n squared steps,",
"start": 3103.75,
"duration": 3.58
},
{
"text": "even if, for instance,\nthe list is sorted?",
"start": 3107.33,
"duration": 3.88
},
{
"text": "So suppose our 8 volunteers here\nwere already 1, 2, 3, 4, 5, 6, 7, 8.",
"start": 3111.21,
"duration": 4.58
},
{
"text": "Which of those algorithms would\nstill have required n squared steps?",
"start": 3115.79,
"duration": 3.79
},
{
"text": "So not linear search or binary\nsearch because those are much lower.",
"start": 3125.52,
"duration": 3.25
},
{
"text": "But insertion, bubble\nsort, selection sort.",
"start": 3128.77,
"duration": 4.55
},
{
"text": "Well, what about selection sort?",
"start": 3133.32,
"duration": 1.66
},
{
"text": "Even if the list is already sorted,\nhow do I find the smallest element?",
"start": 3134.98,
"duration": 3.71
},
{
"text": "I'm lucky and it's right here,\nbut I don't know that yet, right?",
"start": 3138.69,
"duration": 3.62
},
{
"text": "To know that, I have to confidently\nwalk the whole list and realize,",
"start": 3142.31,
"duration": 3.209
},
{
"text": "well, that was a waste of time.",
"start": 3145.519,
"duration": 1.291
},
{
"text": "1 is indeed the smallest element.",
"start": 3146.81,
"duration": 1.54
},
{
"text": "It's sorted.",
"start": 3148.35,
"duration": 0.93
},
{
"text": "How do I find the next smallest element?",
"start": 3149.28,
"duration": 3.09
},
{
"text": "Start at the left.",
"start": 3152.37,
"duration": 0.844
},
{
"text": "But you can ignore number 1.",
"start": 3153.214,
"duration": 1.166
},
{
"text": "So it's a minor savings.",
"start": 3154.38,
"duration": 1.39
},
{
"text": "OK, 2.",
"start": 3155.77,
"duration": 0.77
},
{
"text": "Feel's pretty small, but got to check.",
"start": 3156.54,
"duration": 3.16
},
{
"text": "Dammit, that was the smallest.",
"start": 3159.7,
"duration": 1.65
},
{
"text": "And so selection sort, even in the best\ncase when the list is already sorted,",
"start": 3161.35,
"duration": 5.72
},
{
"text": "is going to take at least\non the order of n squared",
"start": 3167.07,
"duration": 4.09
},
{
"text": "steps because of that naivete of it.",
"start": 3171.16,
"duration": 2.09
},
{
"text": "Because of that underlying\ndesign of just looking",
"start": 3173.25,
"duration": 2.23
},
{
"text": "for the smallest element\nwith no optimizations means",
"start": 3175.48,
"duration": 2.77
},
{
"text": "the algorithm's always going\nto take us that many steps.",
"start": 3178.25,
"duration": 2.34
},
{
"text": "But it doesn't have to be that way.",
"start": 3180.59,
"duration": 1.458
},
{
"text": "What about bubble sort?",
"start": 3182.048,
"duration": 1.052
},
{
"text": "Suppose that all 8 humans are\nsorted, 1 all the way through 8.",
"start": 3183.1,
"duration": 3.52
},
{
"text": "And here I am comparing the first two.",
"start": 3186.62,
"duration": 1.77
},
{
"text": "1 and 2?",
"start": 3188.39,
"duration": 0.76
},
{
"text": "Not out of order.",
"start": 3189.15,
"duration": 1.13
},
{
"text": "2 and 3, 3 and 4, 4 and 5,\n5 and 6, 6 and 7, 7 and 8.",
"start": 3190.28,
"duration": 5.04
},
{
"text": "OK, everything looks good.",
"start": 3195.32,
"duration": 1.43
},
{
"text": "And in particular, what did I not\ndo while walking from left to right?",
"start": 3196.75,
"duration": 5.714
},
{
"text": "I didn't do any swaps.",
"start": 3202.464,
"duration": 0.916
},
{
"text": "So it would be foolish of me\nalgorithmically to do any of that",
"start": 3203.38,
"duration": 3.03
},
{
"text": "again because the answer\nis not going to change.",
"start": 3206.41,
"duration": 2.27
},
{
"text": "And so done.",
"start": 3208.68,
"duration": 0.63
},
{
"text": "It took me n steps to sort\nn elements with bubble sort",
"start": 3209.31,
"duration": 3.69
},
{
"text": "if the list is already sorted.",
"start": 3213.0,
"duration": 2.08
},
{
"text": "So it would be omega of n because in\nthe best case, it takes you n steps.",
"start": 3215.08,
"duration": 4.33
},
{
"text": "Could a sorting algorithm\nbe constant time",
"start": 3219.41,
"duration": 3.58
},
{
"text": "or logarithmic, log n or order of 1?",
"start": 3222.99,
"duration": 3.74
},
{
"text": "Or omega of 1 rather?",
"start": 3226.73,
"duration": 3.32
},
{
"text": "Can you sort n elements in\nlogarithmic time or constant time?",
"start": 3230.05,
"duration": 5.494
},
{
"text": "What's the intuition there?",
"start": 3239.26,
"duration": 1.36
},
{
"text": "These are kind of like now the\nfundamental meaning of computing",
"start": 3240.62,
"duration": 3.36
},
{
"text": "and what you can actually do.",
"start": 3243.98,
"duration": 1.63
},
{
"text": "What does it mean for me to\nask, can you sort n elements",
"start": 3245.61,
"duration": 3.08
},
{
"text": "in log n time or constant time?",
"start": 3248.69,
"duration": 2.37
},
{
"text": "Well, that effectively\nis like saying, can you",
"start": 3251.06,
"duration": 2.76
},
{
"text": "sort n elements without even\nlooking at some of those elements?",
"start": 3253.82,
"duration": 4.81
},
{
"text": "Because both log n and\n1-- or mathematically,",
"start": 3258.63,
"duration": 3.14
},
{
"text": "and if you don't recall, take it on\nfaith today-- less than omega of n",
"start": 3261.77,
"duration": 4.19
},
{
"text": "in general.",
"start": 3265.96,
"duration": 1.27
},
{
"text": "So can you possibly,\nintuitively, in the real world,",
"start": 3267.23,
"duration": 3.29
},
{
"text": "sort n elements in some random\norder in fewer than n steps?",
"start": 3270.52,
"duration": 6.17
},
{
"text": "Yeah.",
"start": 3276.69,
"duration": 1.098
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 3277.788,
"duration": 0.916
},
{
"text": "SPEAKER 1: Good question.",
"start": 3283.779,
"duration": 1.041
},
{
"text": "Could you make the whole\nlist a big integer?",
"start": 3284.82,
"duration": 1.86
},
{
"text": "You could, that and other tricks.",
"start": 3286.68,
"duration": 1.73
},
{
"text": "But to do that, you're going to\nneed to touch or somehow manipulate",
"start": 3288.41,
"duration": 4.28
},
{
"text": "all of those values at least once\nto kind of do that, I would think.",
"start": 3292.69,
"duration": 3.83
},
{
"text": "And so you've already spent n steps.",
"start": 3296.52,
"duration": 2.824
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 3299.344,
"duration": 0.916
},
{
"text": "SPEAKER 1: OK.",
"start": 3303.197,
"duration": 0.583
},
{
"text": "So if you have a like guessing\nalgorithm-- yes, this is sorted.",
"start": 3303.78,
"duration": 4.4
},
{
"text": "That's constant time.",
"start": 3308.18,
"duration": 1.009
},
{
"text": "You're just not always correct.",
"start": 3309.189,
"duration": 1.291
},
{
"text": "So I should clarify, can you\nsort correctly n elements",
"start": 3310.48,
"duration": 3.86
},
{
"text": "without necessarily looking at\nall n-- the short answer is no.",
"start": 3314.34,
"duration": 3.24
},
{
"text": "There is like a fundamental\nlimit of computation.",
"start": 3317.58,
"duration": 2.3
},
{
"text": "And also, just human intuition here.",
"start": 3319.88,
"duration": 1.89
},
{
"text": "You can't possibly claim to me and\nconvince me, in a court of law even,",
"start": 3321.77,
"duration": 4.53
},
{
"text": "that these n elements are\nsorted if you can't even",
"start": 3326.3,
"duration": 2.48
},
{
"text": "testify to having looked\nat all n of those elements.",
"start": 3328.78,
"duration": 2.88
},
{
"text": "It's just not possible given\nthe computational model",
"start": 3331.66,
"duration": 2.47
},
{
"text": "we've been discussing where a computer\ncan only look at one element at a time.",
"start": 3334.13,
"duration": 3.89
},
{
"text": "So sorting is out of the question.",
"start": 3338.02,
"duration": 1.85
},
{
"text": "But an algorithm that\ntakes omega of one step?",
"start": 3339.87,
"duration": 4.85
},
{
"text": "For instance in the best case, when\nmight an algorithm need only one step?",
"start": 3344.72,
"duration": 5.64
},
{
"text": "How about something like linear\nsearch or even binary search?",
"start": 3350.36,
"duration": 3.93
},
{
"text": "The running time of those algorithms\nwas big O of n and big O of log n",
"start": 3354.29,
"duration": 4.98
},
{
"text": "respectively.",
"start": 3359.27,
"duration": 0.95
},
{
"text": "Linear search, binary search.",
"start": 3360.22,
"duration": 2.8
},
{
"text": "What's the lower bound on those\ntwo algorithms' running times?",
"start": 3363.02,
"duration": 2.91
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 3370.407,
"duration": 0.933
},
{
"text": "SPEAKER 1: Yeah, it's omega of 1.",
"start": 3371.34,
"duration": 1.6
},
{
"text": "But why?",
"start": 3372.94,
"duration": 1.99
},
{
"text": "Derek wasn't so lucky.",
"start": 3374.93,
"duration": 1.08
},
{
"text": "But AJ, last year, touched\nthe number 50-- voila, 1 step.",
"start": 3376.01,
"duration": 3.87
},
{
"text": "And that was actually, while\nsort of bad pedagogy for us,",
"start": 3379.88,
"duration": 3.42
},
{
"text": "was a perfect manifestation\nof yes, in the best",
"start": 3383.3,
"duration": 2.78
},
{
"text": "case the lower bound on your running\ntime might indeed just be one step.",
"start": 3386.08,
"duration": 3.43
},
{
"text": "Or two steps, but some\nconstant number of steps.",
"start": 3389.51,
"duration": 2.54
},
{
"text": "So we have a range of these options.",
"start": 3392.05,
"duration": 2.05
},
{
"text": "Now, sometimes these ranges coincide.",
"start": 3394.1,
"duration": 2.73
},
{
"text": "If your big O notation, so to speak,\nand your omega notation, so to speak,",
"start": 3396.83,
"duration": 4.16
},
{
"text": "are one in the same values, you\ncan claim that the algorithm",
"start": 3400.99,
"duration": 2.95
},
{
"text": "has a running time in capital Theta.",
"start": 3403.94,
"duration": 2.77
},
{
"text": "So theta just means when big\nO and omega are the same,",
"start": 3406.71,
"duration": 3.35
},
{
"text": "you can instead use this formula and\nsort of convey two thoughts at once.",
"start": 3410.06,
"duration": 3.69
},
{
"text": "But for now, the takeaway\nis that as best we've",
"start": 3413.75,
"duration": 2.48
},
{
"text": "seen for something like sorting,\nthe best we've done so far, at least",
"start": 3416.23,
"duration": 4.64
},
{
"text": "in the worst case, is\nbig O of n squared.",
"start": 3420.87,
"duration": 2.022
},
{
"text": "And this doesn't feel very good,\nespecially since sorting and searching",
"start": 3422.892,
"duration": 2.958
},
{
"text": "is all around us.",
"start": 3425.85,
"duration": 0.84
},
{
"text": "Anyone with an iPhone or an Android.",
"start": 3426.69,
"duration": 1.714
},
{
"text": "I mean, there's so much data that\nwe're carrying around in our pockets",
"start": 3428.404,
"duration": 2.916
},
{
"text": "these days, let alone in the cloud\nand on our laptops and desktops,",
"start": 3431.32,
"duration": 3.08
},
{
"text": "that it's just generally\ngood practice to keep sorted.",
"start": 3434.4,
"duration": 2.65
},
{
"text": "In your phone book, it\nwould be pretty tedious",
"start": 3437.05,
"duration": 2.08
},
{
"text": "if all of your friends and family were\nin random order in the contacts list.",
"start": 3439.13,
"duration": 3.77
},
{
"text": "And you had to like scroll through\nthe whole darn list, big O of n,",
"start": 3442.9,
"duration": 3.31
},
{
"text": "to find someone.",
"start": 3446.21,
"duration": 1.43
},
{
"text": "No, instead we have a\nsearch box, of course.",
"start": 3447.64,
"duration": 1.952
},
{
"text": "And most of us probably wouldn't\nblindly scroll through the whole list.",
"start": 3449.592,
"duration": 2.958
},
{
"text": "But even that search box, if you start\ntyping in D-E-R to look up Derek,",
"start": 3452.55,
"duration": 4.36
},
{
"text": "or S-M-I-T-H to find Smith.",
"start": 3456.91,
"duration": 2.58
},
{
"text": "Well, how is iOS?",
"start": 3459.49,
"duration": 1.35
},
{
"text": "How is Android finding Mike\nSmith or finding Derek?",
"start": 3460.84,
"duration": 3.54
},
{
"text": "Those pieces of software themselves\nhave algorithms that underneath the hood",
"start": 3464.38,
"duration": 5.92
},
{
"text": "are hopefully leveraging smarter\nalgorithms than we've even seen here.",
"start": 3470.3,
"duration": 4.277
},
{
"text": "Because especially as you have more\nand more friends, more and more family",
"start": 3474.577,
"duration": 3.083
},
{
"text": "members, even big O of n squared\nstarts to feel kind of slow",
"start": 3477.66,
"duration": 3.92
},
{
"text": "as we can see here.",
"start": 3481.58,
"duration": 1.37
},
{
"text": "Let me go ahead and open up an example.",
"start": 3482.95,
"duration": 4.384
},
{
"text": "So let's take a look at a demonstration.",
"start": 3487.334,
"duration": 1.666
},
{
"text": "Here is a visualization that someone\non the internet kindly put together.",
"start": 3489.0,
"duration": 3.31
},
{
"text": "And it focuses on sorting numbers.",
"start": 3492.31,
"duration": 1.96
},
{
"text": "But rather than just show the numbers\ntextually as 1, 2, 3, 4, 5, 6, 7, 8,",
"start": 3494.27,
"duration": 3.56
},
{
"text": "it instead shows them as bar.",
"start": 3497.83,
"duration": 1.36
},
{
"text": "So the shorter the bar,\nthe smaller the number.",
"start": 3499.19,
"duration": 2.05
},
{
"text": "The taller the bar,\nthe taller the number.",
"start": 3501.24,
"duration": 1.956
},
{
"text": "And let me go ahead and\nincrease the speed of this,",
"start": 3503.196,
"duration": 2.124
},
{
"text": "just so it doesn't get too tedious.",
"start": 3505.32,
"duration": 1.61
},
{
"text": "And let's take a quick\nlook at bubble sort.",
"start": 3506.93,
"duration": 3.39
},
{
"text": "Now, notice what's happening.",
"start": 3510.32,
"duration": 1.69
},
{
"text": "The two red bars adjacently\nare the ones that are",
"start": 3512.01,
"duration": 3.21
},
{
"text": "being compared and potentially swapped.",
"start": 3515.22,
"duration": 1.9
},
{
"text": "And you'll notice that just like in\nour human demo, what is happening over",
"start": 3517.12,
"duration": 3.13
},
{
"text": "there on the right-hand side?",
"start": 3520.25,
"duration": 3.525
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 3523.775,
"duration": 1.059
},
{
"text": "SPEAKER 1: Yeah.",
"start": 3524.834,
"duration": 0.666
},
{
"text": "So the biggest elements seem to be\nbubbling up, if you will, to the top.",
"start": 3525.5,
"duration": 4.71
},
{
"text": "Even though there's still a lot of\nwork to be done to the left of those,",
"start": 3530.21,
"duration": 3.64
},
{
"text": "we indeed have the ability here to see\nthe list getting sorted progressively.",
"start": 3533.85,
"duration": 7.394
},
{
"text": "But you know, I'm already getting bored.",
"start": 3541.244,
"duration": 1.666
},
{
"text": "This algorithm doesn't feel very fast.",
"start": 3542.91,
"duration": 1.583
},
{
"text": "It's very pretty.",
"start": 3544.493,
"duration": 0.907
},
{
"text": "It's very correct, it would\nseem, but it's a little slow.",
"start": 3545.4,
"duration": 3.09
},
{
"text": "Let's try another one to see\nif it's any better than that.",
"start": 3548.49,
"duration": 3.67
},
{
"text": "That's the spoiler.",
"start": 3552.16,
"duration": 0.84
},
{
"text": "That's what it should look like.",
"start": 3553.0,
"duration": 1.333
},
{
"text": "Let's try our friend selection\nsort, which is already sorted.",
"start": 3554.333,
"duration": 3.477
},
{
"text": "Let me stop this.",
"start": 3557.81,
"duration": 2.71
},
{
"text": "Let me click on Randomize Array.",
"start": 3560.52,
"duration": 3.86
},
{
"text": "And now click Selection Sort.",
"start": 3564.38,
"duration": 1.7
},
{
"text": "And what's happening here?",
"start": 3566.08,
"duration": 1.29
},
{
"text": "This is like me walking across\nthe audience again and again",
"start": 3567.37,
"duration": 4.0
},
{
"text": "and again and again.",
"start": 3571.37,
"duration": 1.27
},
{
"text": "You don't see any of\nthis bubbling effect,",
"start": 3572.64,
"duration": 2.02
},
{
"text": "but you do see the smallest\nelement being selected again",
"start": 3574.66,
"duration": 4.03
},
{
"text": "and again and again.",
"start": 3578.69,
"duration": 1.59
},
{
"text": "So we're kind of cleaning up\nthat mess one step at a time.",
"start": 3580.28,
"duration": 3.65
},
{
"text": "It's still going to take some\nsteps, but you can perhaps",
"start": 3583.93,
"duration": 2.35
},
{
"text": "see it a little better\nand a little faster here.",
"start": 3586.28,
"duration": 2.42
},
{
"text": "And spoiler alert, when we skip forward\nto the end, that's what it looks like.",
"start": 3588.7,
"duration": 3.95
},
{
"text": "If we now randomize it one last\ntime and do insertion sort,",
"start": 3592.65,
"duration": 4.35
},
{
"text": "this one kind of feels\nand looks different.",
"start": 3597.0,
"duration": 3.97
},
{
"text": "It's kind of mostly\nfixing things, but then it",
"start": 3600.97,
"duration": 2.487
},
{
"text": "kind of goes in and fills in the gaps.",
"start": 3603.457,
"duration": 1.583
},
{
"text": "Because indeed, it's moving forward\none at a time, grabbing the element,",
"start": 3605.04,
"duration": 3.35
},
{
"text": "and then shifting the element as\nneeded to make room for whatever number",
"start": 3608.39,
"duration": 3.22
},
{
"text": "it's encountered.",
"start": 3611.61,
"duration": 1.22
},
{
"text": "So that's why sometimes\nit only takes a few steps",
"start": 3612.83,
"duration": 2.054
},
{
"text": "because you find where it belongs.",
"start": 3614.884,
"duration": 1.416
},
{
"text": "That time it took a while to\nfind the space that it belongs.",
"start": 3616.3,
"duration": 4.3
},
{
"text": "But generally, the list is\ngetting more and more sorted.",
"start": 3620.6,
"duration": 2.71
},
{
"text": "And once we do get to\nthe very end, this one",
"start": 3623.31,
"duration": 2.81
},
{
"text": "we can actually feel\nbeing a little faster.",
"start": 3626.12,
"duration": 1.98
},
{
"text": "Which isn't necessarily a testament\nto it being fundamentally better.",
"start": 3628.1,
"duration": 2.874
},
{
"text": "All of these remain on the\norder of n squared steps.",
"start": 3630.974,
"duration": 3.296
},
{
"text": "And now indeed, it's starting to\ndrag, kind of like our blue books.",
"start": 3634.27,
"duration": 2.83
},
{
"text": "And now we're actually complete.",
"start": 3637.1,
"duration": 1.8
},
{
"text": "But what if we were to\ncompare these things?",
"start": 3638.9,
"duration": 3.19
},
{
"text": "Bubble sort on the left,\nselection sort in the middle,",
"start": 3642.09,
"duration": 2.63
},
{
"text": "and then a third algorithm that we've\nnot seen this time called merge sort.",
"start": 3644.72,
"duration": 4.06
},
{
"text": "So insertion sort is roughly\nthe same as all of these.",
"start": 3648.78,
"duration": 2.39
},
{
"text": "So this visualization lets us try three.",
"start": 3651.17,
"duration": 2.295
},
{
"text": "To start this, I have to click on them.",
"start": 3653.465,
"duration": 1.625
},
{
"text": "So there's a little\nbit of a fudge factor",
"start": 3655.09,
"duration": 1.708
},
{
"text": "here where I have to click on all\nthree programs quickly in succession",
"start": 3656.798,
"duration": 2.972
},
{
"text": "to see them.",
"start": 3659.77,
"duration": 0.72
},
{
"text": "But let's see if we can't\ndo fundamentally better.",
"start": 3660.49,
"duration": 3.63
},
{
"text": "Merge sort is our new\nfriend on the right.",
"start": 3664.12,
"duration": 4.78
},
{
"text": "Oh my god.",
"start": 3668.9,
"duration": 0.65
},
{
"text": "And these are different visualizations,\nbut they're the same algorithms.",
"start": 3672.97,
"duration": 3.9
},
{
"text": "And it's not that they're\njust poorly implemented.",
"start": 3676.87,
"duration": 2.14
},
{
"text": "It's arguably that\nthey're poorly designed.",
"start": 3679.01,
"duration": 2.49
},
{
"text": "They are all correct,\nbut merge sort clearly",
"start": 3681.5,
"duration": 3.81
},
{
"text": "seems to have some upsides\nover selection sort.",
"start": 3685.31,
"duration": 2.307
},
{
"text": "And if you'll take it on faith for\nnow, just because we can only fit three",
"start": 3687.617,
"duration": 3.083
},
{
"text": "on the screen, insertion sort, too.",
"start": 3690.7,
"duration": 2.39
},
{
"text": "You see the bigger elements\nbubbling up to the top.",
"start": 3693.09,
"duration": 2.21
},
{
"text": "You see us selecting.",
"start": 3695.3,
"duration": 1.78
},
{
"text": "Again, it turns out this person\nimplemented selection sort",
"start": 3697.08,
"duration": 3.285
},
{
"text": "by selecting the biggest element.",
"start": 3700.365,
"duration": 1.375
},
{
"text": "But that's fundamentally equivalent\nto selecting the smallest element.",
"start": 3701.74,
"duration": 2.916
},
{
"text": "And that's because you can see\nthem all stacking here in this way.",
"start": 3704.656,
"duration": 3.594
},
{
"text": "But my god, I wonder,\ncan me start this again?",
"start": 3708.25,
"duration": 4.26
},
{
"text": "Let's try.",
"start": 3712.51,
"duration": 0.5
},
{
"text": "Let's see if we can lap it.",
"start": 3713.01,
"duration": 1.11
},
{
"text": "Come on.",
"start": 3714.12,
"duration": 0.29
},
{
"text": "Come on.",
"start": 3714.41,
"duration": 0.5
},
{
"text": "Come on.",
"start": 3714.91,
"duration": 0.93
},
{
"text": "Come on.",
"start": 3715.84,
"duration": 2.27
},
{
"text": "Oh, so close.",
"start": 3718.11,
"duration": 0.96
},
{
"text": "All right.",
"start": 3719.07,
"duration": 0.5
},
{
"text": "Had I not talked as much.",
"start": 3719.57,
"duration": 1.041
},
{
"text": "So merge sort.",
"start": 3720.611,
"duration": 0.759
},
{
"text": "Where is this magical algorithm?",
"start": 3721.37,
"duration": 2.08
},
{
"text": "What are we actually doing wasting\ntime on these other things?",
"start": 3723.45,
"duration": 3.96
},
{
"text": "Well, let's consider exactly that, but\nwe need sort of a secret ingredient.",
"start": 3727.41,
"duration": 3.86
},
{
"text": "And let me revisit Mike\nSmith for just a moment.",
"start": 3731.27,
"duration": 2.292
},
{
"text": "So you'll recall, this\nwas the pseudocode",
"start": 3733.562,
"duration": 1.708
},
{
"text": "that we had from Mike Smith in week 0.",
"start": 3735.27,
"duration": 2.17
},
{
"text": "And we decided when Mike\nis earlier in the book",
"start": 3737.44,
"duration": 3.98
},
{
"text": "or when Mike is later in the book,\nto just go to an earlier step.",
"start": 3741.42,
"duration": 3.87
},
{
"text": "Thereby, inducing some kind of loop.",
"start": 3745.29,
"duration": 2.27
},
{
"text": "But suppose we changed that\nlanguage to be this instead.",
"start": 3747.56,
"duration": 3.18
},
{
"text": "Don't go to a specific line number.",
"start": 3750.74,
"duration": 1.85
},
{
"text": "Don't go to some earlier step.",
"start": 3752.59,
"duration": 2.21
},
{
"text": "But just more generally,\nsay, search for Mike",
"start": 3754.8,
"duration": 2.46
},
{
"text": "in the left half of the book or search\nfor Mike in the right half of the book.",
"start": 3757.26,
"duration": 3.25
},
{
"text": "This is borrowing an idea that\nI proposed a moment ago when",
"start": 3760.51,
"duration": 3.45
},
{
"text": "we were searching for something else.",
"start": 3763.96,
"duration": 2.28
},
{
"text": "And what word did we\nascribe to this kind",
"start": 3766.24,
"duration": 2.14
},
{
"text": "of approach of this cyclical\nuse of your own definition?",
"start": 3768.38,
"duration": 5.5
},
{
"text": "Yeah.",
"start": 3773.88,
"duration": 0.69
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 3774.57,
"duration": 0.38
},
{
"text": "SPEAKER 1: Recursion.",
"start": 3774.95,
"duration": 0.99
},
{
"text": "So recursion is actually\nthis secret ingredient",
"start": 3775.94,
"duration": 2.86
},
{
"text": "that we can leverage, both\nintuitively and in code,",
"start": 3778.8,
"duration": 2.75
},
{
"text": "to implement this new and improved\nfourth algorithm, merge sort.",
"start": 3781.55,
"duration": 4.27
},
{
"text": "And indeed, this we'll use\ndemonstrative of a class of algorithms",
"start": 3785.82,
"duration": 3.117
},
{
"text": "that doesn't behave in quite the\nsame way fundamentally as selection",
"start": 3788.937,
"duration": 2.833
},
{
"text": "sort, insertion sort, and bubble sort.",
"start": 3791.77,
"duration": 1.583
},
{
"text": "Indeed, you can do better\nthan big O of n squared.",
"start": 3793.353,
"duration": 2.477
},
{
"text": "You can do much better, as you felt\na moment ago with visualization.",
"start": 3795.83,
"duration": 3.76
},
{
"text": "And merge sort is one such\nalgorithm with which we can do that.",
"start": 3799.59,
"duration": 3.25
},
{
"text": "And amazingly, the pseudocode\ncode is this simple.",
"start": 3802.84,
"duration": 3.16
},
{
"text": "When you're given n elements, if\nn is less than 2, just return.",
"start": 3806.0,
"duration": 4.17
},
{
"text": "If you have fewer than 2 elements, the\nlist is of size 1, which is sorted,",
"start": 3810.17,
"duration": 3.44
},
{
"text": "or size 0, which is also\nmeaninglessly sorted.",
"start": 3813.61,
"duration": 2.65
},
{
"text": "So you're done.",
"start": 3816.26,
"duration": 1.199
},
{
"text": "So that's kind of a base\ncase, like a default scenario.",
"start": 3817.459,
"duration": 2.291
},
{
"text": "Let's just make sure that no\nmatter what, we eventually",
"start": 3819.75,
"duration": 2.291
},
{
"text": "quit, even if the list is super-small.",
"start": 3822.041,
"duration": 2.399
},
{
"text": "But then, the magic is hidden\nin those last three lines.",
"start": 3824.44,
"duration": 2.84
},
{
"text": "Else, sort the left\nhalf of the elements,",
"start": 3827.28,
"duration": 2.93
},
{
"text": "then sort the right\nhalf of the elements,",
"start": 3830.21,
"duration": 1.76
},
{
"text": "which is completely punting so to speak.",
"start": 3831.97,
"duration": 2.13
},
{
"text": "Just kind of recursively\ncalling yourself.",
"start": 3834.1,
"duration": 2.04
},
{
"text": "But the key detail here is that then\nyou have to merge the sorted halves.",
"start": 3836.14,
"duration": 4.72
},
{
"text": "You're not just looking for Mike to the\nleft and looking for Mike to the right.",
"start": 3840.86,
"duration": 3.312
},
{
"text": "You're doing something on the\nleft, something on the right,",
"start": 3844.172,
"duration": 2.458
},
{
"text": "sorting each half, but then you have\nto kind of weave things together.",
"start": 3846.63,
"duration": 3.43
},
{
"text": "And we'll see how\nexpensive that actually is.",
"start": 3850.06,
"duration": 2.85
},
{
"text": "So let's take an example.",
"start": 3852.91,
"duration": 1.3
},
{
"text": "And I mocked this up with some\nvery simple animation so we",
"start": 3854.21,
"duration": 3.82
},
{
"text": "could walk through it step-by-step.",
"start": 3858.03,
"duration": 1.585
},
{
"text": "But consider the following.",
"start": 3859.615,
"duration": 1.125
},
{
"text": "So here is that same\nlist from before where",
"start": 3860.74,
"duration": 1.791
},
{
"text": "we had a whole bunch of volunteers.",
"start": 3862.531,
"duration": 1.699
},
{
"text": "But rather than call up humans,\nwe'll just do this visually.",
"start": 3864.23,
"duration": 2.58
},
{
"text": "Let me consider the fact that\nthis is really just an array.",
"start": 3866.81,
"duration": 3.245
},
{
"text": "So I'm just going to box\neverything like this.",
"start": 3870.055,
"duration": 2.015
},
{
"text": "And this is actually key that we\nhave random access to these elements.",
"start": 3872.07,
"duration": 3.28
},
{
"text": "We can jump right to\nthe elements we want",
"start": 3875.35,
"duration": 1.82
},
{
"text": "and code ultimately, too, if we cared.",
"start": 3877.17,
"duration": 2.16
},
{
"text": "And now, let's focus\non the left-hand side.",
"start": 3879.33,
"duration": 2.35
},
{
"text": "So I've wrapped 4, 8,\n6, 2 in a solid line",
"start": 3881.68,
"duration": 4.682
},
{
"text": "and left everything else\ndash because I want to focus",
"start": 3886.362,
"duration": 2.208
},
{
"text": "our attention on sorting the left half.",
"start": 3888.57,
"duration": 2.23
},
{
"text": "So again, to rewind\nthis is the algorithm.",
"start": 3890.8,
"duration": 2.51
},
{
"text": "And the goal at hand is\nto walk through visually",
"start": 3893.31,
"duration": 2.0
},
{
"text": "an example whereby we sort 8 elements.",
"start": 3895.31,
"duration": 2.684
},
{
"text": "And we do that by sorting the\nleft half, sorting the right half,",
"start": 3897.994,
"duration": 2.666
},
{
"text": "and then somehow merging\nthese things together.",
"start": 3900.66,
"duration": 3.16
},
{
"text": "So how do we do this?",
"start": 3903.82,
"duration": 1.14
},
{
"text": "Well, let's consider the left half.",
"start": 3904.96,
"duration": 2.23
},
{
"text": "All right.",
"start": 3907.19,
"duration": 0.95
},
{
"text": "How do I sort a list of 4 elements?",
"start": 3908.14,
"duration": 2.07
},
{
"text": "What does it mean to sort the left half?",
"start": 3910.21,
"duration": 1.78
},
{
"text": "Well, what algorithms do I have in\nmy toolkit for sorting elements?",
"start": 3911.99,
"duration": 2.9
},
{
"text": "Yeah, selection sort, insertion\nsort, bubble sort, but-- merge sort.",
"start": 3917.64,
"duration": 4.68
},
{
"text": "And that's where this\ngets weird quickly.",
"start": 3922.32,
"duration": 2.29
},
{
"text": "You want to use your same algorithm to\nsort the left-hand side of this list.",
"start": 3924.61,
"duration": 4.324
},
{
"text": "And yet, we haven't even\nfinished defining this algorithm,",
"start": 3928.934,
"duration": 2.416
},
{
"text": "but that's going to be OK we'll see.",
"start": 3931.35,
"duration": 2.13
},
{
"text": "So let's sort the left half.",
"start": 3933.48,
"duration": 1.19
},
{
"text": "How do you sort the left half of a list?",
"start": 3934.67,
"duration": 1.666
},
{
"text": "Well, you sort a list of size 4.",
"start": 3936.336,
"duration": 1.494
},
{
"text": "What does that mean?",
"start": 3937.83,
"duration": 0.85
},
{
"text": "How do you sort a list of size 4?",
"start": 3938.68,
"duration": 2.66
},
{
"text": "Sort the left half of that.",
"start": 3941.34,
"duration": 2.19
},
{
"text": "So let's focus on 4 and 8.",
"start": 3943.53,
"duration": 2.19
},
{
"text": "How do you sort a list of size 2?",
"start": 3945.72,
"duration": 1.96
},
{
"text": "Merge sort it.",
"start": 3947.68,
"duration": 1.25
},
{
"text": "So how do you sort a list of size 2?",
"start": 3948.93,
"duration": 1.98
},
{
"text": "Sort the left half.",
"start": 3950.91,
"duration": 1.86
},
{
"text": "OK, beautifully.",
"start": 3952.77,
"duration": 1.16
},
{
"text": "Done.",
"start": 3953.93,
"duration": 1.72
},
{
"text": "Done.",
"start": 3955.65,
"duration": 1.29
},
{
"text": "Sort the right half.",
"start": 3956.94,
"duration": 1.51
},
{
"text": "Nice, done.",
"start": 3958.45,
"duration": 1.56
},
{
"text": "I mean, I'm doing real\nwork, or claiming to.",
"start": 3960.01,
"duration": 2.57
},
{
"text": "But now I have to do something more.",
"start": 3962.58,
"duration": 1.69
},
{
"text": "Now I have to merge the two halves.",
"start": 3964.27,
"duration": 1.46
},
{
"text": "So I'm taking a step back.",
"start": 3965.73,
"duration": 1.33
},
{
"text": "I have two lists now, one\nof size 1, one of size 1.",
"start": 3967.06,
"duration": 3.579
},
{
"text": "I have to merge these\nthings, two together.",
"start": 3970.639,
"duration": 1.791
},
{
"text": "Which comes first, 4 or 8?",
"start": 3972.43,
"duration": 2.69
},
{
"text": "4.",
"start": 3975.12,
"duration": 0.67
},
{
"text": "So let's create some extra space for it.",
"start": 3975.79,
"duration": 2.03
},
{
"text": "Let's put 4 here and let's put 8 here.",
"start": 3977.82,
"duration": 3.53
},
{
"text": "So here's a key detail\nwith merge sort, kind",
"start": 3981.35,
"duration": 2.394
},
{
"text": "of cheating, at least at the\nmoment, I'm using some extra space.",
"start": 3983.744,
"duration": 2.666
},
{
"text": "So I hope you won't mind.",
"start": 3986.41,
"duration": 1.23
},
{
"text": "To achieve this, I'm using\nmore memory, more RAM,",
"start": 3987.64,
"duration": 2.76
},
{
"text": "that I wasn't allowing myself\nfor selection sort, bubble",
"start": 3990.4,
"duration": 2.53
},
{
"text": "sort, or insertion sort.",
"start": 3992.93,
"duration": 1.011
},
{
"text": "OK.",
"start": 3993.941,
"duration": 0.499
},
{
"text": "So now it's going to be\neasy to get lost quickly.",
"start": 3994.44,
"duration": 2.041
},
{
"text": "So what have I just done?",
"start": 3996.481,
"duration": 1.239
},
{
"text": "I have sorted a list of size 2\nby sorting the left half, done.",
"start": 3997.72,
"duration": 4.06
},
{
"text": "Right half, done.",
"start": 4001.78,
"duration": 1.27
},
{
"text": "Merging it together.",
"start": 4003.05,
"duration": 1.4
},
{
"text": "So now I have a sorted list of size 2.",
"start": 4004.45,
"duration": 3.69
},
{
"text": "Rewind the story.",
"start": 4008.14,
"duration": 0.87
},
{
"text": "What step comes next?",
"start": 4009.01,
"duration": 2.76
},
{
"text": "Sort the right half.",
"start": 4011.77,
"duration": 2.06
},
{
"text": "That was of size 2.",
"start": 4013.83,
"duration": 1.2
},
{
"text": "So if you kind of mentally buffer\nall of the to-dos that we're doing,",
"start": 4015.03,
"duration": 3.5
},
{
"text": "and then pluck them off as we go,\nyou'll see where the story goes.",
"start": 4018.53,
"duration": 3.68
},
{
"text": "Now I want to sort the right\nhalf of the original list.",
"start": 4022.21,
"duration": 2.31
},
{
"text": "Sorry, the right half of the\nleft half of the original list.",
"start": 4024.52,
"duration": 4.32
},
{
"text": "How do I do that?",
"start": 4028.84,
"duration": 0.94
},
{
"text": "Sort of left half, done.",
"start": 4029.78,
"duration": 1.7
},
{
"text": "Sort the right half, done.",
"start": 4031.48,
"duration": 1.77
},
{
"text": "Merge them together.",
"start": 4033.25,
"duration": 1.21
},
{
"text": "What comes first, 6 or 2?",
"start": 4034.46,
"duration": 1.86
},
{
"text": "OK.",
"start": 4036.32,
"duration": 0.5
},
{
"text": "So let's give ourselves a\nlittle more memory for that",
"start": 4036.82,
"duration": 1.76
},
{
"text": "so we have a place to put it.",
"start": 4038.58,
"duration": 1.33
},
{
"text": "2.",
"start": 4039.91,
"duration": 0.97
},
{
"text": "And then 6.",
"start": 4040.88,
"duration": 1.271
},
{
"text": "All right.",
"start": 4042.151,
"duration": 0.499
},
{
"text": "So it doesn't look like all\nthat much progress, frankly.",
"start": 4042.65,
"duration": 2.93
},
{
"text": "My left half of the list is now 4,\n8, 2, 6, which is not really sorted.",
"start": 4045.58,
"duration": 3.74
},
{
"text": "But we'll get there.",
"start": 4049.32,
"duration": 1.21
},
{
"text": "What step comes next?",
"start": 4050.53,
"duration": 1.55
},
{
"text": "I've just sorted the right half of\nthe left half of my original list.",
"start": 4052.08,
"duration": 4.701
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 4056.781,
"duration": 2.409
},
{
"text": "SPEAKER 1: You're missing a step.",
"start": 4059.19,
"duration": 1.47
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 4060.66,
"duration": 0.97
},
{
"text": "SPEAKER 1: Merge, that third step.",
"start": 4061.63,
"duration": 1.98
},
{
"text": "Once you've sorted the\nleft half of something,",
"start": 4063.61,
"duration": 2.0
},
{
"text": "then you've sorted the\nright half of something.",
"start": 4065.61,
"duration": 1.958
},
{
"text": "Now you have to merge them or\nweave them together somehow.",
"start": 4067.568,
"duration": 2.942
},
{
"text": "So the left half of the list in\nthe story at the moment is 4 and 8.",
"start": 4070.51,
"duration": 3.25
},
{
"text": "The right half is 2 and 6.",
"start": 4073.76,
"duration": 1.75
},
{
"text": "So here's where mentally\nyou can kind of bring out",
"start": 4075.51,
"duration": 2.309
},
{
"text": "your fingers to think through this sort\nof conceptually, or in pseudocode code.",
"start": 4077.819,
"duration": 3.291
},
{
"text": "Here's the left list.",
"start": 4081.11,
"duration": 1.69
},
{
"text": "Here's the right list,\nor the right half.",
"start": 4082.8,
"duration": 2.13
},
{
"text": "So how do I merge these two together?",
"start": 4084.93,
"duration": 1.577
},
{
"text": "Well, it turns out--\nand you can see it now.",
"start": 4086.507,
"duration": 1.833
},
{
"text": "Before it was idiotic that we\njust were merging lists of size 1.",
"start": 4088.34,
"duration": 2.85
},
{
"text": "It's pretty easy.",
"start": 4091.19,
"duration": 0.89
},
{
"text": "Here now, we have something\nsubstantive to talk about.",
"start": 4092.08,
"duration": 2.51
},
{
"text": "So I have one list here, one list here.",
"start": 4094.59,
"duration": 2.33
},
{
"text": "Which element from these two\nlists obviously comes first?",
"start": 4096.92,
"duration": 4.67
},
{
"text": "So 2.",
"start": 4101.59,
"duration": 1.11
},
{
"text": "And so what I'm going to do is then\n2 is going to have to come down here.",
"start": 4102.7,
"duration": 3.369
},
{
"text": "And then I can advance my\nright hand so to speak.",
"start": 4106.069,
"duration": 2.491
},
{
"text": "And now, compare 4 and 6.",
"start": 4108.56,
"duration": 1.379
},
{
"text": "What's going to come next?",
"start": 4109.939,
"duration": 1.641
},
{
"text": "4.",
"start": 4111.58,
"duration": 0.72
},
{
"text": "Now I can advance my left hand.",
"start": 4112.3,
"duration": 1.389
},
{
"text": "I compare 8 and 6.",
"start": 4113.689,
"duration": 1.311
},
{
"text": "Which comes next?",
"start": 4115.0,
"duration": 1.29
},
{
"text": "6.",
"start": 4116.29,
"duration": 0.63
},
{
"text": "Now, my right hand, its job is done.",
"start": 4116.92,
"duration": 1.93
},
{
"text": "I have only one more to do.",
"start": 4118.85,
"duration": 2.31
},
{
"text": "And this.",
"start": 4121.16,
"duration": 0.54
},
{
"text": "So what's key in the merging\nis that you essentially",
"start": 4121.7,
"duration": 2.6
},
{
"text": "have this left hand and\nthis right hand concept.",
"start": 4124.3,
"duration": 2.49
},
{
"text": "Each of them kind of steps forward\nover time, but you never go back.",
"start": 4126.79,
"duration": 3.77
},
{
"text": "You never double back.",
"start": 4130.56,
"duration": 1.29
},
{
"text": "So it's this sort of linear relationship\nwith your left and right hand",
"start": 4131.85,
"duration": 2.968
},
{
"text": "as you're merging the lists together.",
"start": 4134.818,
"duration": 1.541
},
{
"text": "So pictorially, let's see that.",
"start": 4136.359,
"duration": 1.5
},
{
"text": "We compare 4 and 2.",
"start": 4137.859,
"duration": 2.091
},
{
"text": "2 goes first.",
"start": 4139.95,
"duration": 1.09
},
{
"text": "Then, 4.",
"start": 4141.04,
"duration": 1.04
},
{
"text": "Then, 6.",
"start": 4142.08,
"duration": 0.92
},
{
"text": "Then, 8.",
"start": 4143.0,
"duration": 0.649
},
{
"text": "Where am I in the story?",
"start": 4143.649,
"duration": 1.33
},
{
"text": "I mean, we've been droning\non for some time now.",
"start": 4144.979,
"duration": 3.09
},
{
"text": "I have just successfully sorted what?",
"start": 4148.069,
"duration": 3.511
},
{
"text": "The left half of the original\nlist, which means the next step is?",
"start": 4151.58,
"duration": 3.568
},
{
"text": "AUDIENCE: Sort the right.",
"start": 4155.148,
"duration": 1.041
},
{
"text": "SPEAKER 1: Sort the right\nhalf of the original list.",
"start": 4156.189,
"duration": 2.29
},
{
"text": "So I can box that in to\ndraw attention to it.",
"start": 4158.479,
"duration": 2.181
},
{
"text": "How do I sort a list of size 4?",
"start": 4160.66,
"duration": 1.52
},
{
"text": "Well, that's really\njust 2 lists of size 2.",
"start": 4162.18,
"duration": 2.13
},
{
"text": "Let's sort the left half.",
"start": 4164.31,
"duration": 1.21
},
{
"text": "How do I sort a list of size 2?",
"start": 4165.52,
"duration": 1.5
},
{
"text": "Well, that's really just a\nlist of-- 2 lists of size 1.",
"start": 4167.02,
"duration": 4.28
},
{
"text": "Done.",
"start": 4171.3,
"duration": 0.5
},
{
"text": "1 is sorted.",
"start": 4171.8,
"duration": 0.929
},
{
"text": "Done.",
"start": 4172.729,
"duration": 0.5
},
{
"text": "7 is sorted.",
"start": 4173.229,
"duration": 0.851
},
{
"text": "Now I have to merge them together.",
"start": 4174.08,
"duration": 1.48
},
{
"text": "1 comes first, then 7.",
"start": 4175.56,
"duration": 3.009
},
{
"text": "OK, now sort the right half of the\nright half of the original list.",
"start": 4178.569,
"duration": 4.071
},
{
"text": "OK.",
"start": 4182.64,
"duration": 0.85
},
{
"text": "Sort the left half.",
"start": 4183.49,
"duration": 1.0
},
{
"text": "Done.",
"start": 4184.49,
"duration": 0.55
},
{
"text": "Right half.",
"start": 4185.04,
"duration": 0.6
},
{
"text": "Done.",
"start": 4185.64,
"duration": 0.67
},
{
"text": "Merge them together\ninto some extra space.",
"start": 4186.31,
"duration": 2.629
},
{
"text": "3, and then 5.",
"start": 4188.939,
"duration": 2.271
},
{
"text": "Now where am I in the story?",
"start": 4191.21,
"duration": 1.939
},
{
"text": "Now I have sorted the left\nhalf of the original right half",
"start": 4193.149,
"duration": 4.085
},
{
"text": "and the right half of\nthe original right half,",
"start": 4197.234,
"duration": 1.916
},
{
"text": "so now I have to merge them together.",
"start": 4199.15,
"duration": 2.81
},
{
"text": "So 1, 3, 5, 7.",
"start": 4201.96,
"duration": 5.24
},
{
"text": "Almost there.",
"start": 4207.2,
"duration": 0.94
},
{
"text": "Now we're sort of rewinding in time.",
"start": 4208.14,
"duration": 1.94
},
{
"text": "Now we're at the very first\nchapter in the story--",
"start": 4210.08,
"duration": 2.49
},
{
"text": "sort left half, sort right half, merge.",
"start": 4212.57,
"duration": 2.37
},
{
"text": "I have that one final merge step.",
"start": 4214.94,
"duration": 1.64
},
{
"text": "So what comes first from the\nleft half and the right half?",
"start": 4216.58,
"duration": 3.96
},
{
"text": "1, 2-- even if you've\nlost track of the story,",
"start": 4220.54,
"duration": 3.43
},
{
"text": "the answer's going to be\n1, 2, 3, 4, 5, 6, 7, 8.",
"start": 4223.97,
"duration": 2.0
},
{
"text": "But 1, 2, 3.",
"start": 4225.97,
"duration": 2.24
},
{
"text": "But notice what's\nhappening here in effect.",
"start": 4228.21,
"duration": 1.97
},
{
"text": "Whatever code is implementing this,\nit's as though my right and left",
"start": 4230.18,
"duration": 3.67
},
{
"text": "fingers are just moving from left to\nright, plucking off the element that",
"start": 4233.85,
"duration": 4.72
},
{
"text": "is indeed then the smallest.",
"start": 4238.57,
"duration": 3.61
},
{
"text": "That was a heck of a lot of work.",
"start": 4242.18,
"duration": 1.42
},
{
"text": "And frankly, that story seemed to take\nlonger to tell than any of the others.",
"start": 4243.6,
"duration": 5.64
},
{
"text": "But what happened?",
"start": 4249.24,
"duration": 1.156
},
{
"text": "And in fact, I've left deliberately,\nwith this little animation",
"start": 4250.396,
"duration": 2.624
},
{
"text": "of sorts, on the screen the\nremnants of where we came.",
"start": 4253.02,
"duration": 2.7
},
{
"text": "And it looks like I\nreally cheated, though.",
"start": 4255.72,
"duration": 1.88
},
{
"text": "I seemed to first say,\nhey, I need some extra RAM.",
"start": 4257.6,
"duration": 2.68
},
{
"text": "And I took it.",
"start": 4260.28,
"duration": 0.94
},
{
"text": "And then I didn't\nmention I need more RAM.",
"start": 4261.22,
"duration": 1.83
},
{
"text": "I didn't mention I needed even more RAM.",
"start": 4263.05,
"duration": 1.666
},
{
"text": "So this seems to have taken like four\ntimes as much total memory than any",
"start": 4264.716,
"duration": 3.863
},
{
"text": "of our previous algorithms, but\nthat's not actually the case.",
"start": 4268.579,
"duration": 2.541
},
{
"text": "I left this here pictorially\nso we could see the history.",
"start": 4271.12,
"duration": 2.71
},
{
"text": "Technically, you do need more RAM to\nimplement this algorithm, merge sort.",
"start": 4273.83,
"duration": 3.741
},
{
"text": "But we could have cut corners.",
"start": 4277.571,
"duration": 1.249
},
{
"text": "Instead of merging down\nhere, we could have just",
"start": 4278.82,
"duration": 2.24
},
{
"text": "merged back into our original chunk.",
"start": 4281.06,
"duration": 1.68
},
{
"text": "And so we could have just bounced\nbetween two separate arrays,",
"start": 4282.74,
"duration": 2.77
},
{
"text": "but this is just a little more\nclear in terms of remnants.",
"start": 4285.51,
"duration": 3.51
},
{
"text": "So how many steps did this take?",
"start": 4289.02,
"duration": 2.04
},
{
"text": "Well, how many times did I\ndivide my original list in half,",
"start": 4291.06,
"duration": 4.39
},
{
"text": "in half, in half effectively?",
"start": 4295.45,
"duration": 1.325
},
{
"text": "I had 8 elements here.",
"start": 4299.45,
"duration": 1.58
},
{
"text": "And that was really like, if\nyou divide it up differently,",
"start": 4301.03,
"duration": 2.74
},
{
"text": "two bigger halves and two bigger halves.",
"start": 4303.77,
"duration": 1.78
},
{
"text": "But if you divide it again,\nthat's like two really big halves,",
"start": 4305.55,
"duration": 3.17
},
{
"text": "and then you get one big list.",
"start": 4308.72,
"duration": 2.03
},
{
"text": "So it would seem that starting\nhere, I divided it 1, 2, 3 times.",
"start": 4310.75,
"duration": 4.69
},
{
"text": "I did some splitting.",
"start": 4315.44,
"duration": 0.916
},
{
"text": "Left half, right half,\nleft half, right half.",
"start": 4316.356,
"duration": 1.874
},
{
"text": "And any time you split something\nin half, in half, in half,",
"start": 4318.23,
"duration": 2.26
},
{
"text": "in half, what's the running time of\nanything involving like halving again",
"start": 4320.49,
"duration": 3.16
},
{
"text": "and again and again?",
"start": 4323.65,
"duration": 0.833
},
{
"text": "It's like binary search.",
"start": 4327.687,
"duration": 2.743
},
{
"text": "Log n.",
"start": 4330.43,
"duration": 0.66
},
{
"text": "Log n.",
"start": 4331.09,
"duration": 0.78
},
{
"text": "So any time you see in\ncomputer science more",
"start": 4331.87,
"duration": 2.76
},
{
"text": "generally, certainly CS50 in\nupcoming weeks, this division",
"start": 4334.63,
"duration": 2.894
},
{
"text": "and conquering again and\nagain and again where",
"start": 4337.524,
"duration": 1.916
},
{
"text": "you're dividing something in half,\nodds are logarithmic running time",
"start": 4339.44,
"duration": 3.4
},
{
"text": "is somehow at play.",
"start": 4342.84,
"duration": 1.34
},
{
"text": "But this algorithm, merge sort, surely\ncannot run in big O of log n time.",
"start": 4344.18,
"duration": 5.93
},
{
"text": "Because again, you can't sort n\nelements in less than linear time",
"start": 4350.11,
"duration": 5.14
},
{
"text": "because you'd be guessing\nthat everything is sorted.",
"start": 4355.25,
"duration": 3.08
},
{
"text": "So log n is not the final\nanswer here, but there",
"start": 4358.33,
"duration": 2.54
},
{
"text": "is something logarithmic happening.",
"start": 4360.87,
"duration": 2.19
},
{
"text": "However, even though we did\na left half/right half thing,",
"start": 4363.06,
"duration": 4.17
},
{
"text": "a left half/right half thing,\na left half/right hand,",
"start": 4367.23,
"duration": 2.56
},
{
"text": "thing sort of a total of three\ntimes, from here to here to here",
"start": 4369.79,
"duration": 2.98
},
{
"text": "to here, at which point we were done.",
"start": 4372.77,
"duration": 2.47
},
{
"text": "On every row that's on\nthe screen if you will,",
"start": 4375.24,
"duration": 3.92
},
{
"text": "what did I do with my\nleft and right hand?",
"start": 4379.16,
"duration": 2.66
},
{
"text": "I sort of always did n steps.",
"start": 4381.82,
"duration": 5.01
},
{
"text": "You can really see it up here.",
"start": 4386.83,
"duration": 1.39
},
{
"text": "How did I merge this last thing?",
"start": 4388.22,
"duration": 1.594
},
{
"text": "I had to touch all 8 elements\nby walking through the list.",
"start": 4389.814,
"duration": 2.416
},
{
"text": "How did I merge these two left halves?",
"start": 4392.23,
"duration": 2.21
},
{
"text": "Well, I had to do this.",
"start": 4394.44,
"duration": 1.3
},
{
"text": "And then I had to do this.",
"start": 4395.74,
"duration": 1.76
},
{
"text": "So if you kind of consider the remnants\nof my finger touching the screen,",
"start": 4397.5,
"duration": 4.24
},
{
"text": "every time I did a divide and conquer,\nI had to touch every element in order",
"start": 4401.74,
"duration": 3.6
},
{
"text": "to merge them together.",
"start": 4405.34,
"duration": 1.48
},
{
"text": "So I did log n things.",
"start": 4406.82,
"duration": 2.36
},
{
"text": "And every time I did that, I\nincurred n steps of merging.",
"start": 4409.18,
"duration": 5.13
},
{
"text": "So log n things times n is going\nto give me big O of n log n.",
"start": 4414.31,
"duration": 8.05
},
{
"text": "So this was among the options on our\nsort of menu of possible running times,",
"start": 4422.36,
"duration": 3.49
},
{
"text": "at least that we'll focus on right now.",
"start": 4425.85,
"duration": 1.9
},
{
"text": "This is bigger than log n, of course.",
"start": 4427.75,
"duration": 1.845
},
{
"text": "Because you're multiplying it by n but.",
"start": 4429.595,
"duration": 1.625
},
{
"text": "It's smaller than n squared.",
"start": 4431.22,
"duration": 1.32
},
{
"text": "Because if log n is less than n, then\nsurely n times log n is less than n.",
"start": 4432.54,
"duration": 3.9
},
{
"text": "And so the running\ntime here of merge sort",
"start": 4436.44,
"duration": 2.12
},
{
"text": "is indeed going to be big O of log n.",
"start": 4438.56,
"duration": 5.07
},
{
"text": "Any questions on this here?",
"start": 4443.63,
"duration": 3.31
},
{
"text": "If I may, let me point\nout one other approach",
"start": 4446.94,
"duration": 2.55
},
{
"text": "for seeing this same thing as follows.",
"start": 4449.49,
"duration": 2.28
},
{
"text": "You can actually glean\nthis kind of detail",
"start": 4451.77,
"duration": 2.5
},
{
"text": "more formally, especially if you're the\nmathy type, from the pseudocode itself.",
"start": 4454.27,
"duration": 3.64
},
{
"text": "We didn't have to walk through this\nwhole verbal exercise or visualization",
"start": 4457.91,
"duration": 3.29
},
{
"text": "thereof.",
"start": 4461.2,
"duration": 0.5
},
{
"text": "What if we just go back to basics and\njust analyze our own pseudocode code,",
"start": 4461.7,
"duration": 3.44
},
{
"text": "or our own C code\neventually, line by line?",
"start": 4465.14,
"duration": 2.97
},
{
"text": "So here's the original algorithm.",
"start": 4468.11,
"duration": 1.66
},
{
"text": "How many steps does this take to\njust check if n is less than 2?",
"start": 4469.77,
"duration": 3.58
},
{
"text": "Return.",
"start": 4473.35,
"duration": 0.56
},
{
"text": "We're done.",
"start": 4473.91,
"duration": 1.6
},
{
"text": "Big O of what?",
"start": 4475.51,
"duration": 1.676
},
{
"text": "There's just one step.",
"start": 4477.186,
"duration": 0.938
},
{
"text": "Or maybe, it's two, like\nthe if and then the return.",
"start": 4478.124,
"duration": 2.166
},
{
"text": "But it's constant.",
"start": 4480.29,
"duration": 0.77
},
{
"text": "It's one or two.",
"start": 4481.06,
"duration": 0.79
},
{
"text": "We can debate that, but it's constant.",
"start": 4481.85,
"duration": 1.61
},
{
"text": "It has nothing to do with the size of n.",
"start": 4483.46,
"duration": 1.98
},
{
"text": "You're just making a finite\nnumber of decisions there, 1.",
"start": 4485.44,
"duration": 3.33
},
{
"text": "So you know what?",
"start": 4488.77,
"duration": 1.61
},
{
"text": "The running time, which I'm going\nto formulaically say is t of n.",
"start": 4490.38,
"duration": 3.61
},
{
"text": "So the running time when\nyour input is of size n,",
"start": 4493.99,
"duration": 2.86
},
{
"text": "is just going to be like on the\norder of constant time, big O of 1,",
"start": 4496.85,
"duration": 2.95
},
{
"text": "whenever n is less than 2.",
"start": 4499.8,
"duration": 2.12
},
{
"text": "This is not a very bold claim.",
"start": 4501.92,
"duration": 1.29
},
{
"text": "It's sort of like I'm plucking off\nthe easiest part of the question,",
"start": 4503.21,
"duration": 2.48
},
{
"text": "but it's at least correct.",
"start": 4505.69,
"duration": 1.22
},
{
"text": "If you have a small\nlist, it's constant time.",
"start": 4506.91,
"duration": 2.11
},
{
"text": "The harder question is when we\nanalyze the rest of the algorithm.",
"start": 4509.02,
"duration": 3.48
},
{
"text": "How many steps does it take to\nsort the left half of elements?",
"start": 4512.5,
"duration": 3.59
},
{
"text": "How many steps does it take to\nsort the right half of elements?",
"start": 4516.09,
"duration": 2.95
},
{
"text": "And how many steps does\nit take to sort-- rather,",
"start": 4519.04,
"duration": 5.12
},
{
"text": "to merge the sorted halves?",
"start": 4524.16,
"duration": 1.56
},
{
"text": "So we have three questions to answer.",
"start": 4525.72,
"duration": 2.96
},
{
"text": "And let me propose this.",
"start": 4528.68,
"duration": 1.385
},
{
"text": "You can kind of punt.",
"start": 4530.065,
"duration": 0.875
},
{
"text": "And this is the beauty of recursion.",
"start": 4530.94,
"duration": 1.18
},
{
"text": "You can sort of answer the\nquestion with the question.",
"start": 4532.12,
"duration": 2.249
},
{
"text": "The running time to sort n\nelements is really the running time",
"start": 4534.369,
"duration": 3.531
},
{
"text": "to sort n over 2 elements, the left\nhalf, plus the running time to sort n",
"start": 4537.9,
"duration": 4.37
},
{
"text": "over 2 elements, the right\nhalf, plus the merging step,",
"start": 4542.27,
"duration": 3.12
},
{
"text": "which I claimed per my sort\nof left/right finger intuition",
"start": 4545.39,
"duration": 4.7
},
{
"text": "is big O of n steps linear.",
"start": 4550.09,
"duration": 2.08
},
{
"text": "And now this holds if n is\ngreater than or equal to 2.",
"start": 4552.17,
"duration": 3.68
},
{
"text": "Now, unfortunately, this is like a\nrecurrence if you will, mathematically.",
"start": 4555.85,
"duration": 3.96
},
{
"text": "This really is a cyclical definition.",
"start": 4559.81,
"duration": 2.0
},
{
"text": "We really need to be able to\ngeneralize this and explain",
"start": 4561.81,
"duration": 3.53
},
{
"text": "it a little more formulaically.",
"start": 4565.34,
"duration": 2.4
},
{
"text": "But indeed, take a guess.",
"start": 4567.74,
"duration": 1.45
},
{
"text": "If you have your old physics\ntextbook or your math textbook,",
"start": 4569.19,
"duration": 2.73
},
{
"text": "what does this recurrence actually\nequal if you multiply it all out",
"start": 4571.92,
"duration": 3.09
},
{
"text": "and prove it mathematically?",
"start": 4575.01,
"duration": 1.33
},
{
"text": "What's the running\ntime total of something",
"start": 4578.74,
"duration": 1.75
},
{
"text": "where you do some function of n over\n2 plus some function of n over 2",
"start": 4580.49,
"duration": 4.2
},
{
"text": "plus some number of linear steps where\neach of those inner running times",
"start": 4584.69,
"duration": 5.0
},
{
"text": "is recursively defined?",
"start": 4589.69,
"duration": 2.03
},
{
"text": "And just to be clear, the\nreason this is like non-obvious",
"start": 4591.72,
"duration": 3.61
},
{
"text": "and should be kind of over\nmost heads, at least if you're",
"start": 4595.33,
"duration": 2.75
},
{
"text": "less familiar with this world, is that\nI'm saying that the running time, t, is",
"start": 4598.08,
"duration": 4.15
},
{
"text": "a function of the running time, t.",
"start": 4602.23,
"duration": 1.5
},
{
"text": "Like again, that's defining\na word with the word itself.",
"start": 4603.73,
"duration": 4.63
},
{
"text": "But it turns out there are ways to\nprove this inductively, mathematically.",
"start": 4608.36,
"duration": 3.24
},
{
"text": "And indeed, if you actually multiply\nthis all out in your textbook,",
"start": 4611.6,
"duration": 2.791
},
{
"text": "you will get something on\nthe order of n times log n.",
"start": 4614.391,
"duration": 4.449
},
{
"text": "So where has that left us?",
"start": 4618.84,
"duration": 1.204
},
{
"text": "We've introduced a whole number of\nalgorithms here, the last of which,",
"start": 4620.044,
"duration": 2.916
},
{
"text": "merge sort, gives us this ability\nto actually solve problems",
"start": 4622.96,
"duration": 3.66
},
{
"text": "much faster than any of the others.",
"start": 4626.62,
"duration": 2.01
},
{
"text": "But in each case, are we able to\napply some general formulaic analysis,",
"start": 4628.63,
"duration": 4.34
},
{
"text": "asymptotic notation so to speak--\nbig O, big Omega, and big Theta, that",
"start": 4632.97,
"duration": 5.35
},
{
"text": "describes in general terms how much\ntime these kinds of things take.",
"start": 4638.32,
"duration": 5.2
},
{
"text": "So let's now translate one of today's\nkey ingredients to actual C code",
"start": 4643.52,
"duration": 4.36
},
{
"text": "so that we can see how we can\nleverage this programmatically.",
"start": 4647.88,
"duration": 2.97
},
{
"text": "So here in CS50 IDE, I've got\nan example, sigma 0 and sigma 1.",
"start": 4650.85,
"duration": 5.0
},
{
"text": "Both of which at the end of\nthe day do the same thing,",
"start": 4655.85,
"duration": 2.6
},
{
"text": "but they do it differently.",
"start": 4658.45,
"duration": 1.22
},
{
"text": "And in sigma 0 here, we\nhave the following code.",
"start": 4659.67,
"duration": 2.26
},
{
"text": "A sigma function that takes as input\nan integer m as its sole argument",
"start": 4661.93,
"duration": 4.96
},
{
"text": "and it has a return value of type int.",
"start": 4666.89,
"duration": 1.59
},
{
"text": "So it's going to return a number.",
"start": 4668.48,
"duration": 1.375
},
{
"text": "Main takes no command line arguments.",
"start": 4669.855,
"duration": 1.545
},
{
"text": "So no arg v, no arg c this time.",
"start": 4671.4,
"duration": 1.84
},
{
"text": "But inside of main is code that's going\nto pester the user again and again",
"start": 4673.24,
"duration": 3.72
},
{
"text": "until he or she gives us a positive\ninteger as per this condition",
"start": 4676.96,
"duration": 4.43
},
{
"text": "down here.",
"start": 4681.39,
"duration": 0.94
},
{
"text": "And then, notice down here I'm\ngoing to call a function sigma,",
"start": 4682.33,
"duration": 3.51
},
{
"text": "passing in whatever\nthe user's input was.",
"start": 4685.84,
"duration": 1.85
},
{
"text": "10, for instance.",
"start": 4687.69,
"duration": 1.08
},
{
"text": "Or 11.",
"start": 4688.77,
"duration": 0.76
},
{
"text": "Or some other value.",
"start": 4689.53,
"duration": 1.15
},
{
"text": "Storing the answer in answer,\nand then just printing it out.",
"start": 4690.68,
"duration": 3.67
},
{
"text": "And what's nice about\nthe fact that frankly you",
"start": 4694.35,
"duration": 2.12
},
{
"text": "can't see anything else on the screen\nis that for all intents and purposes,",
"start": 4696.47,
"duration": 3.21
},
{
"text": "sigma, the function at the\nmoment, is a black box.",
"start": 4699.68,
"duration": 2.72
},
{
"text": "It is a function whose purpose in life\nis to add all of the numbers from 1 up",
"start": 4702.4,
"duration": 3.23
},
{
"text": "until the user's input and return it.",
"start": 4705.63,
"duration": 1.96
},
{
"text": "And we don't know yet or need to\ncare how it's actually implemented.",
"start": 4707.59,
"duration": 3.99
},
{
"text": "If we do take a look inside that\nblack box down lower in the file,",
"start": 4711.58,
"duration": 4.76
},
{
"text": "you'll see this code here.",
"start": 4716.34,
"duration": 1.62
},
{
"text": "Sigma takes an input, m, as an int.",
"start": 4717.96,
"duration": 3.08
},
{
"text": "Returns an int.",
"start": 4721.04,
"duration": 0.84
},
{
"text": "And what does it do inside?",
"start": 4721.88,
"duration": 1.22
},
{
"text": "Well, I've got what I'll\ncall a counter-variable.",
"start": 4723.1,
"duration": 2.51
},
{
"text": "Called it sum.",
"start": 4725.61,
"duration": 0.9
},
{
"text": "Initialized it to 0.",
"start": 4726.51,
"duration": 1.38
},
{
"text": "And then using a for loop,\niterating from 1 up to m,",
"start": 4727.89,
"duration": 4.01
},
{
"text": "because I want to sum all the\nnumbers from 1 up through the value",
"start": 4731.9,
"duration": 3.63
},
{
"text": "the human has typed in.",
"start": 4735.53,
"duration": 1.48
},
{
"text": "I just want to keep adding\nto the sum that value.",
"start": 4737.01,
"duration": 2.73
},
{
"text": "So it's not just sum plus plus.",
"start": 4739.74,
"duration": 1.59
},
{
"text": "If I did sum plus plus as we keep\nseeing syntactically in examples,",
"start": 4741.33,
"duration": 3.684
},
{
"text": "that would just add 1.",
"start": 4745.014,
"duration": 0.916
},
{
"text": "I want to add in whatever i is.",
"start": 4745.93,
"duration": 2.33
},
{
"text": "Whether it's 1, or 2, or 3,\nas I'm counting all the way",
"start": 4748.26,
"duration": 4.16
},
{
"text": "up through the user's input.",
"start": 4752.42,
"duration": 1.52
},
{
"text": "And then I return sum.",
"start": 4753.94,
"duration": 1.95
},
{
"text": "But the neat thing\nabout sigma is that it",
"start": 4755.89,
"duration": 2.76
},
{
"text": "affords an opportunity for recursion.",
"start": 4758.65,
"duration": 2.13
},
{
"text": "This isn't necessarily a better\nopportunity or more correct,",
"start": 4760.78,
"duration": 3.66
},
{
"text": "but we could view the\nworld a little differently.",
"start": 4764.44,
"duration": 2.35
},
{
"text": "Sigma1.c is identical code in main,\nbut the implementation of sigma",
"start": 4766.79,
"duration": 6.29
},
{
"text": "is fundamentally different.",
"start": 4773.08,
"duration": 1.58
},
{
"text": "And here's where it's kind of\nmind-blowing, at least at first glance.",
"start": 4774.66,
"duration": 3.21
},
{
"text": "You can implement a\nfunction, like sigma,",
"start": 4777.87,
"duration": 2.9
},
{
"text": "in such a way that the\nfunction calls itself.",
"start": 4780.77,
"duration": 3.53
},
{
"text": "Much like the running time for merge\nsort is defined in terms of itself.",
"start": 4784.3,
"duration": 3.76
},
{
"text": "Much like searching\nor sorting a list, it",
"start": 4788.06,
"duration": 2.756
},
{
"text": "can be recursively defined as\nsearching or sorting a smaller list,",
"start": 4790.816,
"duration": 4.664
},
{
"text": "but with the same steps.",
"start": 4795.48,
"duration": 1.43
},
{
"text": "We implement this code in C as follows.",
"start": 4796.91,
"duration": 1.97
},
{
"text": "On this line here, if m is\nless than or equal to 0,",
"start": 4798.88,
"duration": 4.06
},
{
"text": "it's really just a sanity check.",
"start": 4802.94,
"duration": 1.55
},
{
"text": "If the human was messing\nwith me and somehow",
"start": 4804.49,
"duration": 3.15
},
{
"text": "was able to inject a negative value\nor a 0 value into this function,",
"start": 4807.64,
"duration": 4.609
},
{
"text": "I don't want to get stuck in\nsome random, like infinite loop.",
"start": 4812.249,
"duration": 2.541
},
{
"text": "I want to catch that.",
"start": 4814.79,
"duration": 1.02
},
{
"text": "So I'm just going to say less than or\nequal to 0 just to be super-defensive",
"start": 4815.81,
"duration": 3.124
},
{
"text": "when programming return 0.",
"start": 4818.934,
"duration": 1.926
},
{
"text": "It's not correct to say\nthat, but I just want--",
"start": 4820.86,
"duration": 2.31
},
{
"text": "and I'll document this in\nmy comments, for instance.",
"start": 4823.17,
"duration": 2.65
},
{
"text": "Return 0 if the user does not cooperate.",
"start": 4825.82,
"duration": 1.96
},
{
"text": "I need that base case so\nthat stuff stops eventually.",
"start": 4827.78,
"duration": 3.94
},
{
"text": "And then, here's kind\nof the amazing thing.",
"start": 4831.72,
"duration": 2.12
},
{
"text": "In my \"else\" condition,\nis one line of code",
"start": 4833.84,
"duration": 2.84
},
{
"text": "that implements the\nentirety of this function.",
"start": 4836.68,
"duration": 3.7
},
{
"text": "The result of asking me the\nquestion, what is sigma of m,",
"start": 4840.38,
"duration": 3.39
},
{
"text": "is really the same thing as\nsaying m plus sigma of m minus 1.",
"start": 4843.77,
"duration": 8.07
},
{
"text": "In other words, if the goal is to count\nup all of the numbers between 1 and m,",
"start": 4851.84,
"duration": 4.28
},
{
"text": "logically that's the same as counting\nup all the numbers from m to 1.",
"start": 4856.12,
"duration": 4.12
},
{
"text": "And so if I view it that\nway, if you give me m,",
"start": 4860.24,
"duration": 4.48
},
{
"text": "I am going to sort of on my cheat\nsheet write down the number m,",
"start": 4864.72,
"duration": 3.35
},
{
"text": "and then say plus whatever the\nsummation is from m minus 1",
"start": 4868.07,
"duration": 4.05
},
{
"text": "all the way down to 1.",
"start": 4872.12,
"duration": 1.11
},
{
"text": "And you know what?",
"start": 4873.23,
"duration": 0.75
},
{
"text": "I have a function, a piece of code, that\ngives me exactly that answer if I just",
"start": 4873.98,
"duration": 3.88
},
{
"text": "pass-in that slightly smaller value.",
"start": 4877.86,
"duration": 2.7
},
{
"text": "So on first glance, it might\nlook like sigma calls sigma.",
"start": 4880.56,
"duration": 3.81
},
{
"text": "That can't possibly be a good thing.",
"start": 4884.37,
"duration": 2.19
},
{
"text": "But it doesn't do it forever.",
"start": 4886.56,
"duration": 1.48
},
{
"text": "Sigma might call sigma might\ncall sigma might call sigma.",
"start": 4888.04,
"duration": 2.54
},
{
"text": "But at what point in the story\ndoes sigma stop calling sigma?",
"start": 4890.58,
"duration": 4.67
},
{
"text": "AUDIENCE: [INAUDIBLE].",
"start": 4895.25,
"duration": 1.5
},
{
"text": "SPEAKER 1: When it's counted.",
"start": 4896.75,
"duration": 1.32
},
{
"text": "When m, the input, is what?",
"start": 4898.07,
"duration": 3.01
},
{
"text": "Negative.",
"start": 4901.08,
"duration": 0.53
},
{
"text": "Or we shouldn't hit negative ever.",
"start": 4901.61,
"duration": 1.46
},
{
"text": "We should first hit?",
"start": 4903.07,
"duration": 1.231
},
{
"text": "AUDIENCE: 0.",
"start": 4904.301,
"duration": 0.499
},
{
"text": "SPEAKER 1: 0.",
"start": 4904.8,
"duration": 1.01
},
{
"text": "So once m minus 1 gets so small, 1 minus\n1, that it equals 0, this line of code",
"start": 4905.81,
"duration": 6.507
},
{
"text": "is going to kick in.",
"start": 4912.317,
"duration": 0.833
},
{
"text": "And it's going to say return 0.",
"start": 4913.15,
"duration": 1.92
},
{
"text": "Thereby, short circuiting\nthis seemingly infinite loop,",
"start": 4915.07,
"duration": 3.82
},
{
"text": "which does, in fact, terminate\neventually once the input",
"start": 4918.89,
"duration": 3.74
},
{
"text": "gets small enough.",
"start": 4922.63,
"duration": 1.41
},
{
"text": "Now, probably you shouldn't bother\nimplementing code like this.",
"start": 4924.04,
"duration": 3.195
},
{
"text": "If anything, we'll talk\nabout this in future weeks.",
"start": 4927.235,
"duration": 2.125
},
{
"text": "Calling function after function after\nfunction after function after actually",
"start": 4929.36,
"duration": 3.66
},
{
"text": "can take up a lot of memory.",
"start": 4933.02,
"duration": 1.352
},
{
"text": "It can actually cause your\ncomputer to crash in some cases.",
"start": 4934.372,
"duration": 2.458
},
{
"text": "And we'll talk about when and why.",
"start": 4936.83,
"duration": 1.82
},
{
"text": "So this isn't necessarily\nthe best technical decision,",
"start": 4938.65,
"duration": 2.95
},
{
"text": "but it's illustrative of the capability\nwe have in programming to map intuition",
"start": 4941.6,
"duration": 4.48
},
{
"text": "from our binary search or our\nmerge sort into actual code.",
"start": 4946.08,
"duration": 5.301
},
{
"text": "And indeed, there's going to\nbe data structures that we soon",
"start": 4951.381,
"duration": 2.499
},
{
"text": "see far fancier than arrays.",
"start": 4953.88,
"duration": 2.11
},
{
"text": "We're going to see things\nlike link lists, and trees,",
"start": 4955.99,
"duration": 2.39
},
{
"text": "and tries, and hash tables.",
"start": 4958.38,
"duration": 1.46
},
{
"text": "And other data structures\nstill that are going",
"start": 4959.84,
"duration": 2.71
},
{
"text": "to allow us opportunities to implement\nalgorithms on top of those data",
"start": 4962.55,
"duration": 5.22
},
{
"text": "structures so to speak,\nto answer questions",
"start": 4967.77,
"duration": 2.45
},
{
"text": "using an ingredient like this one here.",
"start": 4970.22,
"duration": 2.96
},
{
"text": "But of course, we're left then\nfortunately with a better algorithm",
"start": 4973.18,
"duration": 3.51
},
{
"text": "than something like bubble sort.",
"start": 4976.69,
"duration": 1.5
},
{
"text": "And indeed, this is fairly\nwell-known now it would seem.",
"start": 4978.19,
"duration": 2.75
},
{
"text": "And I thought we'd conclude with\na look at this interview that",
"start": 4980.94,
"duration": 3.13
},
{
"text": "was conducted with a certain senator\nsome years ago who was running",
"start": 4984.07,
"duration": 3.71
},
{
"text": "for the presidency and was asked\nby Google's own Eric Schmidt,",
"start": 4987.78,
"duration": 4.03
},
{
"text": "the CEO at the time, a set\nof interview questions.",
"start": 4991.81,
"duration": 3.06
},
{
"text": "One of which we thought was\nappropriate note to end on here.",
"start": 4994.87,
"duration": 4.45
},
{
"text": "[AUDIO PLAYBACK]",
"start": 4999.32,
"duration": 3.666
},
{
"text": "[APPLAUSE]",
"start": 5002.986,
"duration": 2.334
},
{
"text": "-Now, Senator.",
"start": 5005.32,
"duration": 1.86
},
{
"text": "You're here at Google.",
"start": 5007.18,
"duration": 1.01
},
{
"text": "And I like to think of the\npresidency as a job interview.",
"start": 5008.19,
"duration": 5.71
},
{
"text": "Now, it's hard to get\na job as president.",
"start": 5013.9,
"duration": 3.142
},
{
"text": "You're going [INAUDIBLE] now.",
"start": 5017.042,
"duration": 1.208
},
{
"text": "It's also hard to get a job at Google.",
"start": 5018.25,
"duration": 2.17
},
{
"text": "We have questions.",
"start": 5020.42,
"duration": 2.67
},
{
"text": "And we ask our candidates questions.",
"start": 5023.09,
"duration": 2.58
},
{
"text": "And this one is from Larry Schwimmer.",
"start": 5025.67,
"duration": 3.676
},
{
"text": "[LAUGHTER]",
"start": 5029.346,
"duration": 1.969
},
{
"text": "You guys think I'm kidding?",
"start": 5031.315,
"duration": 1.125
},
{
"text": "It's right here.",
"start": 5032.44,
"duration": 2.46
},
{
"text": "What is the most efficient way to\nsort a million 32-bit integers?",
"start": 5034.9,
"duration": 4.148
},
{
"text": "[LAUGHTER]",
"start": 5039.048,
"duration": 2.922
},
{
"text": "-Well--",
"start": 5041.97,
"duration": 2.4
},
{
"text": "-I'm sorry.",
"start": 5044.37,
"duration": 0.591
},
{
"text": "Maybe--",
"start": 5044.961,
"duration": 0.499
},
{
"text": "-No, no, no, no.",
"start": 5045.46,
"duration": 0.75
},
{
"text": "I think the bubble sort\nwould be the wrong way to go.",
"start": 5046.21,
"duration": 4.98
},
{
"text": "-Come on.",
"start": 5054.19,
"duration": 0.745
},
{
"text": "Who told him this?",
"start": 5054.935,
"duration": 1.565
},
{
"text": "OK.",
"start": 5056.5,
"duration": 1.84
},
{
"text": "I didn't see computer\nscience in your background.",
"start": 5058.34,
"duration": 2.352
},
{
"text": "-We've got our spies in there.",
"start": 5060.692,
"duration": 2.878
},
{
"text": "[END PLAYBACK]",
"start": 5063.57,
"duration": 1.32
},
{
"text": "SPEAKER 1: All right,\nso that's it for week 3.",
"start": 5064.89,
"duration": 2.23
},
{
"text": "We will see you next time.",
"start": 5067.12,
"duration": 1.6
},
{
"text": "SPEAKER 2: So you want\nto know the full story?",
"start": 5076.94,
"duration": 2.352
},
{
"text": "SPEAKER 3: As far back\nas you can remember.",
"start": 5079.292,
"duration": 3.013
},
{
"text": "SPEAKER 2: All right.",
"start": 5082.305,
"duration": 0.875
},
{
"text": "Well, let me tell you.",
"start": 5083.18,
"duration": 2.64
},
{
"text": "The first time I met David Malan,\nI knew he was nothing but trouble.",
"start": 5085.82,
"duration": 4.06
},
{
"text": "SPEAKER 4: There's a David\nJ. Malan here for you.",
"start": 5097.779,
"duration": 2.041
},
{
"text": "SPEAKER 5: Who?",
"start": 5099.82,
"duration": 1.534
},
{
"text": "SPEAKER 4: He says he's in\nyour Computer Science 50 class.",
"start": 5101.354,
"duration": 2.416
},
{
"text": "Wants to talk about his grade.",
"start": 5103.77,
"duration": 2.04
},
{
"text": "SPEAKER 5: Are you kidding me?",
"start": 5105.81,
"duration": 1.44
},
{
"text": "I mean, who does he\nthink he is, Bill Gates?",
"start": 5107.25,
"duration": 3.67
},
{
"text": "All right.",
"start": 5110.92,
"duration": 0.82
},
{
"text": "send him in.",
"start": 5111.74,
"duration": 2.02
}
]