1 00:00:00,000 --> 00:00:05,910 Might I call on, say, two volunteers to kick us off with two, say, algorithms? 2 00:00:05,910 --> 00:00:07,170 Let's see. 3 00:00:07,170 --> 00:00:08,040 Over here? 4 00:00:08,040 --> 00:00:08,730 Yeah. 5 00:00:08,730 --> 00:00:12,570 And let's go over here in front, if we may. 6 00:00:12,570 --> 00:00:14,420 Come on up. 7 00:00:14,420 --> 00:00:15,420 And what are your names? 8 00:00:15,420 --> 00:00:16,360 AUDIENCE: [? Nizari. ?] 9 00:00:16,360 --> 00:00:16,790 SPEAKER 1: Lizari? 10 00:00:16,790 --> 00:00:17,290 AUDIENCE: [? Nizari. ?] 11 00:00:17,290 --> 00:00:18,910 SPEAKER 1: [? Nizari. ?] OK, David. 12 00:00:18,910 --> 00:00:19,660 Nice to meet you. 13 00:00:19,660 --> 00:00:22,530 Come on up, [? Nizari. ?] And over here, what's your name? 14 00:00:22,530 --> 00:00:23,320 AUDIENCE: Eric. 15 00:00:23,320 --> 00:00:24,160 SPEAKER 1: Eric, OK. 16 00:00:24,160 --> 00:00:24,660 David. 17 00:00:24,660 --> 00:00:26,070 And come on up, Brian, as well. 18 00:00:26,070 --> 00:00:27,530 Nice to meet you, Eric. 19 00:00:27,530 --> 00:00:29,420 Eric, [? Nizari. ?] [? Nizari, ?] Eric. 20 00:00:29,420 --> 00:00:30,750 [APPLAUSE] 21 00:00:30,750 --> 00:00:32,490 Come on over here. 22 00:00:32,490 --> 00:00:34,590 So you came on up the stage first. 23 00:00:34,590 --> 00:00:36,390 Would you like to go first or go second? 24 00:00:36,390 --> 00:00:37,130 AUDIENCE: I'll go second. 25 00:00:37,130 --> 00:00:38,370 SPEAKER 1: You're going to go second. 26 00:00:38,370 --> 00:00:39,120 So Eric, you're up first. 27 00:00:39,120 --> 00:00:40,450 Come on over here, if you would. 28 00:00:40,450 --> 00:00:45,120 So Eric, behind these seven doors we have placed, in advance, the number 50. 29 00:00:45,120 --> 00:00:47,430 And we would simply like you, the computer, 30 00:00:47,430 --> 00:00:50,420 to search this array for the number 50. 31 00:00:50,420 --> 00:00:52,300 AUDIENCE: Is it sorted? 32 00:00:52,300 --> 00:00:56,040 SPEAKER 1: I cannot answer that question at this time. 33 00:00:56,040 --> 00:00:58,440 Go. 34 00:00:58,440 --> 00:01:00,150 Oh, and so that the audience knows what's 35 00:01:00,150 --> 00:01:03,030 going on, if you wouldn't mind taking the numbers out to see. 36 00:01:03,030 --> 00:01:04,220 AUDIENCE: This is seven. 37 00:01:04,220 --> 00:01:05,340 SPEAKER 1: Excellent. 38 00:01:05,340 --> 00:01:06,170 Not 50. 39 00:01:06,170 --> 00:01:08,020 AUDIENCE: Should I-- can I take it out? 40 00:01:08,020 --> 00:01:10,680 SPEAKER 1: At this point, yes, you may do whatever you want now. 41 00:01:10,680 --> 00:01:12,450 Just find us 50. 42 00:01:12,450 --> 00:01:13,800 AUDIENCE: Two. 43 00:01:13,800 --> 00:01:14,720 [LAUGHTER] 44 00:01:14,720 --> 00:01:17,070 SPEAKER 1: Very good. 45 00:01:17,070 --> 00:01:18,260 AUDIENCE: One. 46 00:01:18,260 --> 00:01:20,830 SPEAKER 1: Nice. 47 00:01:20,830 --> 00:01:22,140 AUDIENCE: Six. 48 00:01:22,140 --> 00:01:24,950 SPEAKER 1: Very good. 49 00:01:24,950 --> 00:01:25,660 AUDIENCE: Three. 50 00:01:26,160 --> 00:01:26,820 SPEAKER 1: Nice. 51 00:01:26,820 --> 00:01:28,490 AUDIENCE: None of these are close to 50. 52 00:01:28,490 --> 00:01:30,480 SPEAKER 1: No, none of them are close to 50. 53 00:01:30,480 --> 00:01:31,210 AUDIENCE: Four. 54 00:01:31,210 --> 00:01:32,670 SPEAKER 1: Four? 55 00:01:32,670 --> 00:01:34,600 And? 56 00:01:34,600 --> 00:01:35,580 AUDIENCE: 50! 57 00:01:35,580 --> 00:01:36,630 SPEAKER 1: Amazing! 58 00:01:36,630 --> 00:01:37,630 Very well done. 59 00:01:37,630 --> 00:01:39,820 [APPLAUSE] 60 00:01:40,640 --> 00:01:41,270 Very well done. 61 00:01:41,270 --> 00:01:43,250 Now, if I may, Eric, what was the algorithm 62 00:01:43,250 --> 00:01:45,020 via which you found us the number 50? 63 00:01:45,020 --> 00:01:46,050 AUDIENCE: Linear search. 64 00:01:46,050 --> 00:01:48,380 SPEAKER 1: OK, linear search, meaning what to you? 65 00:01:48,380 --> 00:01:52,070 AUDIENCE: You just go in a line, starting from there until there. 66 00:01:52,070 --> 00:01:54,200 SPEAKER 1: OK, that was a very sophisticated answer 67 00:01:54,200 --> 00:01:55,650 to a term we've not yet introduced. 68 00:01:55,650 --> 00:01:59,150 And that's great, linear search from left to right, so literally 69 00:01:59,150 --> 00:01:59,900 following a line. 70 00:01:59,900 --> 00:02:01,820 And was your algorithm correct, would you say? 71 00:02:01,820 --> 00:02:02,460 AUDIENCE: Yes. 72 00:02:02,460 --> 00:02:03,870 SPEAKER 1: OK, so it was correct. 73 00:02:03,870 --> 00:02:05,900 But there's these different parameters that we 74 00:02:05,900 --> 00:02:08,450 want to optimize solutions for not just correctness, but what 75 00:02:08,450 --> 00:02:09,970 other property as well? 76 00:02:09,970 --> 00:02:10,730 AUDIENCE: Design. 77 00:02:10,730 --> 00:02:12,810 SPEAKER 1: So maybe design, right, the efficiency. 78 00:02:12,810 --> 00:02:14,960 So was that the most efficient you could have done? 79 00:02:14,960 --> 00:02:18,020 AUDIENCE: Actually, yeah, I think so. 80 00:02:18,020 --> 00:02:18,800 [LAUGHTER] 81 00:02:18,800 --> 00:02:19,800 SPEAKER 1: And why do you say that? 82 00:02:19,800 --> 00:02:21,810 AUDIENCE: Because-- so the numbers are sorted. 83 00:02:21,810 --> 00:02:25,020 So at the end of the day, I have to look through every single one. 84 00:02:25,020 --> 00:02:25,220 SPEAKER 1: Yeah. 85 00:02:25,220 --> 00:02:27,380 AUDIENCE: And it's just by chance that the 50 was at last. 86 00:02:27,380 --> 00:02:28,170 SPEAKER 1: Exactly. 87 00:02:28,170 --> 00:02:30,230 So it's unfortunate that they were all random. 88 00:02:30,230 --> 00:02:32,540 And I didn't want to tell you because I didn't want to bias your algorithm one 89 00:02:32,540 --> 00:02:33,240 way or the other. 90 00:02:33,240 --> 00:02:36,260 But not knowing if they're sorted and them not even being sorted 91 00:02:36,260 --> 00:02:39,820 means that that is the best you can do, look at all of the doors 92 00:02:39,820 --> 00:02:41,120 to find the number in question. 93 00:02:41,120 --> 00:02:43,760 And maybe you could have gotten lucky, if we had put 50 here. 94 00:02:43,760 --> 00:02:45,560 But in the worst case, Eric was, of course, 95 00:02:45,560 --> 00:02:48,140 going to have to do exactly that, searching all of the boxes. 96 00:02:48,140 --> 00:02:49,340 So thank you, Eric. 97 00:02:49,340 --> 00:02:50,960 Stay on stage with us, if you would, for a moment. 98 00:02:50,960 --> 00:02:53,090 And a round of applause, if we could, for finding 50 so well. 99 00:02:53,090 --> 00:02:53,590 [APPLAUSE] 100 00:02:53,590 --> 00:02:55,980 [? Nizari, ?] could you come on up? 101 00:02:55,980 --> 00:02:58,250 We need you not to look at the numbers, because Brian 102 00:02:58,250 --> 00:02:59,690 needs to do a little bit of magic. 103 00:02:59,690 --> 00:03:02,030 And he's going to put some of the numbers back into the locker. 104 00:03:02,030 --> 00:03:04,110 So literally everyone in the room will know what's 105 00:03:04,110 --> 00:03:05,790 going on except you, at the moment. 106 00:03:05,790 --> 00:03:08,000 But we're going to give you the added bonus this time 107 00:03:08,000 --> 00:03:10,940 of sorting the numbers in advance. 108 00:03:10,940 --> 00:03:13,420 So Brian is in the process of sorting some numbers for us. 109 00:03:13,420 --> 00:03:15,260 The goal at hand, in just a moment, is still 110 00:03:15,260 --> 00:03:17,240 going to be the find the number 50. 111 00:03:17,240 --> 00:03:20,640 I'm really just stalling right now because he's still doing this. 112 00:03:20,640 --> 00:03:24,590 So I don't really have anything interesting to say just yet. 113 00:03:24,590 --> 00:03:25,520 Brian's back now. 114 00:03:25,520 --> 00:03:26,320 Hold on. 115 00:03:26,320 --> 00:03:27,650 And would you like to introduce yourself maybe? 116 00:03:27,650 --> 00:03:28,440 AUDIENCE: I'm [? Nizari. ?] 117 00:03:28,440 --> 00:03:29,450 SPEAKER 1: [? Nizari, ?] and what year are you? 118 00:03:29,450 --> 00:03:31,470 AUDIENCE: I'm a high school student, a senior. 119 00:03:31,470 --> 00:03:32,350 SPEAKER 1: Wonderful. 120 00:03:32,350 --> 00:03:32,990 At what school? 121 00:03:32,990 --> 00:03:34,160 AUDIENCE: Cambridge Rindge and Latin, it's down the street. 122 00:03:34,160 --> 00:03:35,430 SPEAKER 1: Just down the road. 123 00:03:35,430 --> 00:03:36,890 So glad you can join us here today. 124 00:03:36,890 --> 00:03:38,630 And perfect timing, if I may. 125 00:03:38,630 --> 00:03:41,090 Now we have seven lockers here behind you. 126 00:03:41,090 --> 00:03:43,130 And the goal now is to still find the number 50. 127 00:03:43,130 --> 00:03:45,720 But I'm going to tell you that the numbers are sorted. 128 00:03:45,720 --> 00:03:48,960 So what's going to be your algorithm, if not the same as Eric? 129 00:03:48,960 --> 00:03:49,960 AUDIENCE: I will start-- 130 00:03:49,960 --> 00:03:50,370 SPEAKER 1: And here you go. 131 00:03:50,370 --> 00:03:52,310 AUDIENCE: I'm going to start in the middle. 132 00:03:52,310 --> 00:03:54,260 SPEAKER 1: All right, go ahead and show us what's in the middle. 133 00:03:54,260 --> 00:03:55,660 AUDIENCE: Middle number is seven. 134 00:03:55,660 --> 00:03:56,540 SPEAKER 1: All right. 135 00:03:56,540 --> 00:03:58,550 And now what's your next step going to be? 136 00:03:58,550 --> 00:03:59,930 AUDIENCE: So I want to get to 50. 137 00:03:59,930 --> 00:04:02,630 So assuming that they're sorted, I'm going to go this way. 138 00:04:02,630 --> 00:04:03,560 SPEAKER 1: Go to the right, OK. 139 00:04:03,560 --> 00:04:05,970 So we have three lockers remaining on the right-hand side. 140 00:04:05,970 --> 00:04:07,100 What's your instinct now? 141 00:04:07,100 --> 00:04:09,480 AUDIENCE: Mm, I'm going to start with this locker. 142 00:04:09,480 --> 00:04:11,390 SPEAKER 1: OK, this one being in the middle of those three. 143 00:04:11,390 --> 00:04:11,770 And you find? 144 00:04:11,770 --> 00:04:12,800 AUDIENCE: And we got 81. 145 00:04:12,800 --> 00:04:13,290 SPEAKER 1: 81. 146 00:04:13,290 --> 00:04:14,660 AUDIENCE: So I know that's too big. 147 00:04:14,660 --> 00:04:15,480 SPEAKER 1: Way too far. 148 00:04:15,480 --> 00:04:17,120 AUDIENCE: Hoo, so I'm going to go with this one. 149 00:04:17,210 --> 00:04:18,830 SPEAKER 1: Which is now in the middle of the two lockers. 150 00:04:18,830 --> 00:04:19,450 AUDIENCE: And I got 50. 151 00:04:19,450 --> 00:04:22,430 SPEAKER 1: And a round of applause, if we could, for [? Nizari. ?] 152 00:04:22,430 --> 00:04:25,100 [APPLAUSE] 153 00:04:25,100 --> 00:04:27,050 Congratulations and thank you to you both. 154 00:04:27,050 --> 00:04:28,200 So thanks to you both.