1 00:00:00,000 --> 00:00:08,090 2 00:00:08,090 --> 00:00:09,810 >> JASON HIRSCHHORN: Welcome, everyone, to week 10. 3 00:00:09,810 --> 00:00:15,130 This is an exciting week because tomorrow is Quiz 1, which we will get 4 00:00:15,130 --> 00:00:16,400 to in a second. 5 00:00:16,400 --> 00:00:21,770 Today in section, we are going to go over some resources for the quiz, and 6 00:00:21,770 --> 00:00:24,890 then I will answer any and all questions you guys have. 7 00:00:24,890 --> 00:00:27,880 And we will finally end with some practice problems. 8 00:00:27,880 --> 00:00:30,940 >> We can spend the entire section answering questions. 9 00:00:30,940 --> 00:00:33,240 We can spend the entire section going over practice problems. 10 00:00:33,240 --> 00:00:36,890 We will just expand to fill the space and time we have. 11 00:00:36,890 --> 00:00:40,590 >> So I put this list up every week, but it's particularly important this week. 12 00:00:40,590 --> 00:00:44,980 For studying, if you haven't started already, oh boy. 13 00:00:44,980 --> 00:00:46,400 But hopefully you've started already. 14 00:00:46,400 --> 00:00:50,710 And you are going through the materials and resources listed here. 15 00:00:50,710 --> 00:00:54,300 I would highly recommend a number of these. 16 00:00:54,300 --> 00:00:58,780 >> In particular, lecture notes are incredibly important and helpful. 17 00:00:58,780 --> 00:01:02,880 The study.cs50.net provides a great primer on a lot of 18 00:01:02,880 --> 00:01:04,250 the topics we covered. 19 00:01:04,250 --> 00:01:07,810 It also has some great practice problems. 20 00:01:07,810 --> 00:01:11,260 And then, Google is great, too. 21 00:01:11,260 --> 00:01:12,360 I don't know what you'd use it for. 22 00:01:12,360 --> 00:01:14,090 But use Google, as well. 23 00:01:14,090 --> 00:01:16,680 >> Reach out to me if you have any questions, comments, or concerns. 24 00:01:16,680 --> 00:01:19,420 Look over the review session slides from last night. 25 00:01:19,420 --> 00:01:21,540 Or, if you have some time, watch the video. 26 00:01:21,540 --> 00:01:24,930 They provide a lot of helpful material and information. 27 00:01:24,930 --> 00:01:29,730 And try and cover if not all, many of the topics we've covered and that you 28 00:01:29,730 --> 00:01:32,610 might see on the quiz. 29 00:01:32,610 --> 00:01:35,590 >> Speaking of the quiz, that will be tomorrow. 30 00:01:35,590 --> 00:01:37,260 It's 75 minutes long. 31 00:01:37,260 --> 00:01:40,740 Many of you are taking it at 1 o'clock, and some of you are 32 00:01:40,740 --> 00:01:42,740 taking it at 5:30. 33 00:01:42,740 --> 00:01:45,300 For the time you're taking it and the location you're taking it, make sure 34 00:01:45,300 --> 00:01:49,400 you check out the document on the CS50.net homepage. 35 00:01:49,400 --> 00:01:54,340 >> Remember that you can get one 8 1/2 by 11 sheet to take with you. 36 00:01:54,340 --> 00:01:57,310 Oftentimes, people don't use this sheet at all during the quiz. 37 00:01:57,310 --> 00:01:59,740 But really, it is an incredibly helpful study tool. 38 00:01:59,740 --> 00:02:04,370 So putting together that sheet is what I spent probably three or four hours 39 00:02:04,370 --> 00:02:07,110 doing when I was studying for CS50, and that was easily the most helpful 40 00:02:07,110 --> 00:02:08,740 way I could study for the quiz. 41 00:02:08,740 --> 00:02:10,949 So even if you have some other people's study guides to look at and 42 00:02:10,949 --> 00:02:14,740 use as references, I highly recommend making your own study guide, putting 43 00:02:14,740 --> 00:02:15,490 that stuff together. 44 00:02:15,490 --> 00:02:17,335 That really helps you learn all of the material. 45 00:02:17,335 --> 00:02:20,270 46 00:02:20,270 --> 00:02:24,810 >> Last but not least in this section, after the quiz tomorrow there's one 47 00:02:24,810 --> 00:02:25,940 more lecture-- 48 00:02:25,940 --> 00:02:26,960 next Monday. 49 00:02:26,960 --> 00:02:30,430 There's one more section, not next Tuesday before Thanksgiving, but the 50 00:02:30,430 --> 00:02:31,630 Tuesday after that. 51 00:02:31,630 --> 00:02:36,600 We'll be meeting together for a final goodbye party and also doing some cool 52 00:02:36,600 --> 00:02:41,530 things to get you guys excited about further studies in computer science. 53 00:02:41,530 --> 00:02:45,040 >> There's one more project, one more fair, one more hackathon. 54 00:02:45,040 --> 00:02:47,900 We're nearing the end of CS50, which is exciting-- 55 00:02:47,900 --> 00:02:50,950 but also, if you're like me, a little sad. 56 00:02:50,950 --> 00:02:53,950 Before I move on, does anyone have any questions about what 57 00:02:53,950 --> 00:02:55,200 we've covered so far? 58 00:02:55,200 --> 00:03:02,760 59 00:03:02,760 --> 00:03:08,730 >> OK, well let's go over some questions that you have for the quiz and topics 60 00:03:08,730 --> 00:03:09,960 we might cover. 61 00:03:09,960 --> 00:03:11,540 So this is a list that I put together. 62 00:03:11,540 --> 00:03:15,500 It is by no means exhaustive, but hopefully will jog your memory if you 63 00:03:15,500 --> 00:03:20,310 have some questions about any of these topics, or if you have questions about 64 00:03:20,310 --> 00:03:23,260 practice problems from quizzes in years past. 65 00:03:23,260 --> 00:03:27,470 >> I had a couple questions that were emailed to me, but I want to hold off 66 00:03:27,470 --> 00:03:29,490 on those for a second. 67 00:03:29,490 --> 00:03:34,570 Does anybody have any questions, problems they didn't understand, 68 00:03:34,570 --> 00:03:38,100 answers they didn't understand to get us started? 69 00:03:38,100 --> 00:03:39,520 Avi. 70 00:03:39,520 --> 00:03:41,585 >> AUDIENCE: Can you just go over DOM and Ajax really quick? 71 00:03:41,585 --> 00:03:46,540 Like, what we need to know or should understand about them? 72 00:03:46,540 --> 00:03:49,750 >> JASON HIRSCHHORN: I'm going to answer generally this question of, what do I 73 00:03:49,750 --> 00:03:52,100 need to know about given topic x? 74 00:03:52,100 --> 00:03:55,280 Because I have a feeling many of you are going to ask me that, or are 75 00:03:55,280 --> 00:03:56,570 curious about that. 76 00:03:56,570 --> 00:04:02,920 So to the extent that the topic was covered in lecture, or section, or on 77 00:04:02,920 --> 00:04:06,460 study.cs50.net, a problem set, you should be familiar with it. 78 00:04:06,460 --> 00:04:10,580 >> So you don't need to know every type of tag that's available in HTML or 79 00:04:10,580 --> 00:04:15,950 every type of attribute or property you can give something in CSS. 80 00:04:15,950 --> 00:04:20,204 But if you saw it in a lecture example, if you saw it in a problem 81 00:04:20,204 --> 00:04:23,290 set, you should probably be familiar with it, particularly things you saw 82 00:04:23,290 --> 00:04:24,260 in lecture. 83 00:04:24,260 --> 00:04:28,510 So we discussed the document object model a bit in 84 00:04:28,510 --> 00:04:30,530 section, more so in lecture. 85 00:04:30,530 --> 00:04:32,990 You should be familiar with that much of it. 86 00:04:32,990 --> 00:04:34,750 >> And you should be familiar with Ajax to the same extent. 87 00:04:34,750 --> 00:04:38,105 We never saw incredibly advanced or complicated examples of Ajax, so 88 00:04:38,105 --> 00:04:40,920 you're not going to be asked do something incredibly complicated. 89 00:04:40,920 --> 00:04:45,180 But you might be asked, how do I make an Ajax call using jQuery? 90 00:04:45,180 --> 00:04:47,350 Which is something you've seen a number of times before, both in the 91 00:04:47,350 --> 00:04:51,370 review session and in lecture, and it's only two-ish lines of code. 92 00:04:51,370 --> 00:04:53,190 >> So that is something you should be familiar with. 93 00:04:53,190 --> 00:04:55,550 But again, for all these topics, if you've seen it 94 00:04:55,550 --> 00:04:59,220 before, it is fair game. 95 00:04:59,220 --> 00:05:01,540 And we might ask you-- obviously, we're going to ask you things you 96 00:05:01,540 --> 00:05:02,340 haven't seen before. 97 00:05:02,340 --> 00:05:04,240 Coding something you haven't seen before. 98 00:05:04,240 --> 00:05:06,570 Which isn't to say you haven't seen the tools to solve 99 00:05:06,570 --> 00:05:08,120 that problem before. 100 00:05:08,120 --> 00:05:09,200 You have seen those tools. 101 00:05:09,200 --> 00:05:11,160 >> For example, on Quiz 1, if you need to code strlen. 102 00:05:11,160 --> 00:05:12,790 We haven't coded strlen before. 103 00:05:12,790 --> 00:05:14,980 But you know how to use a for loop, you know how to use if conditions. 104 00:05:14,980 --> 00:05:18,570 You know how to write variables in C. It's going to be the same thing here. 105 00:05:18,570 --> 00:05:22,350 You're not going to be asked to do anything you haven't seen before, but 106 00:05:22,350 --> 00:05:25,150 you might be asked to, like, put something together in a novel way, or 107 00:05:25,150 --> 00:05:27,650 solve a different type of problem. 108 00:05:27,650 --> 00:05:30,830 >> Sorry, that wasn't specific to your question, but I can't answer about 109 00:05:30,830 --> 00:05:34,390 every single topic what you do or do not need to know. 110 00:05:34,390 --> 00:05:36,830 But also, sorry, last thing on that. 111 00:05:36,830 --> 00:05:42,900 We have spent significantly more time on link lists than we have on Ajax. 112 00:05:42,900 --> 00:05:46,160 You didn't use Ajax in a problem set. 113 00:05:46,160 --> 00:05:48,510 One of the central features of that problem set that was link lists. 114 00:05:48,510 --> 00:05:50,370 And we spent a lot of time in lecture and section using it. 115 00:05:50,370 --> 00:05:57,080 >> So, odds are link list will come up more often on the quiz than Ajax will. 116 00:05:57,080 --> 00:06:00,390 Or the questions having to do with link list will be worth more points. 117 00:06:00,390 --> 00:06:03,520 So you can certainly focusing and narrow in on things that are more 118 00:06:03,520 --> 00:06:06,720 likely to come up because we have spent more time on them. 119 00:06:06,720 --> 00:06:08,700 >> OK any other questions? 120 00:06:08,700 --> 00:06:09,890 Yeah. 121 00:06:09,890 --> 00:06:13,660 >> AUDIENCE: Can we go over the use of anonymous functions in JavaScript? 122 00:06:13,660 --> 00:06:17,140 I'm a are little confused about that. 123 00:06:17,140 --> 00:06:20,180 >> JASON HIRSCHHORN: So in JavaScript-- 124 00:06:20,180 --> 00:06:24,400 I'm trying to think how I could write this on-- 125 00:06:24,400 --> 00:06:27,590 so let's actually open up this code. 126 00:06:27,590 --> 00:06:31,830 127 00:06:31,830 --> 00:06:36,030 So this is code that we did last week. 128 00:06:36,030 --> 00:06:41,400 And you've seen this before if you were here in section last week. 129 00:06:41,400 --> 00:06:43,180 Or you've seen something similar to this before. 130 00:06:43,180 --> 00:06:44,800 >> But you can look at this first line. 131 00:06:44,800 --> 00:06:46,950 This is how you start-- 132 00:06:46,950 --> 00:06:48,010 everybody's seen this before. 133 00:06:48,010 --> 00:06:51,930 If you want to put some JavaScript code, you put it inside this, assuming 134 00:06:51,930 --> 00:06:53,520 you're using JQuery. 135 00:06:53,520 --> 00:06:56,940 This is saying, don't do anything until the document's loaded. 136 00:06:56,940 --> 00:06:59,940 >> And then, Curt, you see right here we're doing something like this-- 137 00:06:59,940 --> 00:07:02,560 function open paren, closed paren. 138 00:07:02,560 --> 00:07:05,250 So we are not giving this function a name. 139 00:07:05,250 --> 00:07:09,160 We are not going to define this function is supposed to run and then 140 00:07:09,160 --> 00:07:10,830 call it a bunch of times. 141 00:07:10,830 --> 00:07:15,140 We're just saying this document already takes a function. 142 00:07:15,140 --> 00:07:16,690 A couple of things to do. 143 00:07:16,690 --> 00:07:20,670 >> And we don't want to spend the time giving it a name or save it for 144 00:07:20,670 --> 00:07:21,650 perpetuity. 145 00:07:21,650 --> 00:07:24,150 We just want to run some things. 146 00:07:24,150 --> 00:07:27,500 So an anonymous function sort of serves that purpose. 147 00:07:27,500 --> 00:07:30,280 When you're not going to use something over and over again, so you don't need 148 00:07:30,280 --> 00:07:32,420 to give it a name-- you just want to use it once-- 149 00:07:32,420 --> 00:07:36,720 you would just say function, for example, in this case, and you're just 150 00:07:36,720 --> 00:07:38,280 defining something that you could give a name. 151 00:07:38,280 --> 00:07:40,920 >> Like, we could pull this function out and give it a name and then call that 152 00:07:40,920 --> 00:07:41,760 function here. 153 00:07:41,760 --> 00:07:44,270 But we don't need to because we don't want to waste time giving it a name or 154 00:07:44,270 --> 00:07:46,240 wasting something in our name space. 155 00:07:46,240 --> 00:07:47,530 And you'll see that a lot. 156 00:07:47,530 --> 00:07:52,810 For example, we see that a lot in this code, but you've seen this before when 157 00:07:52,810 --> 00:07:54,010 you click something-- 158 00:07:54,010 --> 00:07:55,980 run this type of code. 159 00:07:55,980 --> 00:07:59,850 >> We could define the code that we want to run when we click, in this case, 160 00:07:59,850 --> 00:08:03,450 this ID, as a separate function and then run that function. 161 00:08:03,450 --> 00:08:07,940 But in this case, we're just skipping that step and moving it into here and 162 00:08:07,940 --> 00:08:10,340 just to defining everything that we want to happen and 163 00:08:10,340 --> 00:08:12,450 not giving it a name. 164 00:08:12,450 --> 00:08:15,550 That still might not have answered your question. 165 00:08:15,550 --> 00:08:15,960 >> AUDIENCE: No, it does. 166 00:08:15,960 --> 00:08:18,290 I mean, I guess I just don't really get why it would be a 167 00:08:18,290 --> 00:08:20,800 function at all, though. 168 00:08:20,800 --> 00:08:21,590 Because it's not really being called. 169 00:08:21,590 --> 00:08:23,170 It doesn't really have a name. 170 00:08:23,170 --> 00:08:25,510 >> JASON HIRSCHHORN: It's a function in the sense that it's a series of steps, 171 00:08:25,510 --> 00:08:28,460 like you would put in a function. 172 00:08:28,460 --> 00:08:29,970 And then that's why we call it anonymous function. 173 00:08:29,970 --> 00:08:30,815 We're not going to give it a name. 174 00:08:30,815 --> 00:08:33,159 We're not going to waste trying to name it, but we could. 175 00:08:33,159 --> 00:08:34,890 >> Anonymous functions, you can always give a name. 176 00:08:34,890 --> 00:08:37,620 So for example, this code right here, we could put this code inside a 177 00:08:37,620 --> 00:08:39,929 function and then call this function here. 178 00:08:39,929 --> 00:08:41,600 Instead, we say, we're not going to bother with that. 179 00:08:41,600 --> 00:08:44,390 We're just going to write it all right here. 180 00:08:44,390 --> 00:08:49,840 >> It's like sometimes when you're writing a four loop in C-- you guys 181 00:08:49,840 --> 00:08:51,630 have seen this before-- maybe you're iterating through a forloop 182 00:08:51,630 --> 00:08:53,090 into i equals 0. 183 00:08:53,090 --> 00:08:54,830 I is less than strlen. 184 00:08:54,830 --> 00:08:59,520 Or you're going through some array, you can save array 185 00:08:59,520 --> 00:09:01,580 index i in some variable. 186 00:09:01,580 --> 00:09:02,830 And you use that variable. 187 00:09:02,830 --> 00:09:06,550 So you don't need to rewrite array bracket i over and over and over. 188 00:09:06,550 --> 00:09:08,160 >> And that's sort of like a dummy variable. 189 00:09:08,160 --> 00:09:10,790 It's not serving much purpose other than to make your code a bit cleaner 190 00:09:10,790 --> 00:09:12,120 and easier to read. 191 00:09:12,120 --> 00:09:13,290 Similar function here. 192 00:09:13,290 --> 00:09:15,665 Just makes it a bit easier, but functionally there's no difference. 193 00:09:15,665 --> 00:09:18,620 194 00:09:18,620 --> 00:09:19,330 Does that answer your question? 195 00:09:19,330 --> 00:09:19,970 >> AUDIENCE: Yes. 196 00:09:19,970 --> 00:09:20,720 >> JASON HIRSCHHORN: OK.. 197 00:09:20,720 --> 00:09:21,880 Mario? 198 00:09:21,880 --> 00:09:25,380 >> AUDIENCE: Yesterday they often put function parentheses event. 199 00:09:25,380 --> 00:09:26,420 Does that mean something? 200 00:09:26,420 --> 00:09:30,500 Or is it for things like that they would do 201 00:09:30,500 --> 00:09:35,100 document.ready function event. 202 00:09:35,100 --> 00:09:37,130 >> JASON HIRSCHHORN: We've seen this, and again, these are smaller things that 203 00:09:37,130 --> 00:09:39,590 probably I don't want to spend too much time on. 204 00:09:39,590 --> 00:09:43,200 Because sometimes I don't want people get freaked out that they haven't 205 00:09:43,200 --> 00:09:44,220 heard about these things that much. 206 00:09:44,220 --> 00:09:46,200 But we talked a bit about event handlers. 207 00:09:46,200 --> 00:09:50,360 So something happens, and then this function is executed. 208 00:09:50,360 --> 00:09:53,210 And then we also want to know some details about what 209 00:09:53,210 --> 00:09:54,450 happened in this event. 210 00:09:54,450 --> 00:09:55,730 >> So think back to problem set 4. 211 00:09:55,730 --> 00:09:58,390 That's probably the easiest way to understand that in break out. 212 00:09:58,390 --> 00:09:59,740 There was some code-- 213 00:09:59,740 --> 00:10:01,980 like an event would happen, but event can mean many things. 214 00:10:01,980 --> 00:10:06,240 If could mean the mouse is clicked, it could mean you hit an arrow key, et 215 00:10:06,240 --> 00:10:07,190 cetera, et cetera. 216 00:10:07,190 --> 00:10:09,800 >> But it's all saved in this generic thing called events. 217 00:10:09,800 --> 00:10:12,340 And then we can say, is this event this thing? 218 00:10:12,340 --> 00:10:13,640 Or is this event this thing? 219 00:10:13,640 --> 00:10:15,500 Or, what sort of happened with that event? 220 00:10:15,500 --> 00:10:18,660 So that's why you create that variable there to save that extra information 221 00:10:18,660 --> 00:10:21,420 about what exactly happened that you're going to want to 222 00:10:21,420 --> 00:10:24,840 utilize in the function. 223 00:10:24,840 --> 00:10:28,200 But again, that's probably one of the less important things to be super 224 00:10:28,200 --> 00:10:29,450 familiar with. 225 00:10:29,450 --> 00:10:31,470 226 00:10:31,470 --> 00:10:36,110 >> OK, what other questions have people had, or stumbling blocks they've 227 00:10:36,110 --> 00:10:37,360 encountered while reviewing? 228 00:10:37,360 --> 00:10:41,260 229 00:10:41,260 --> 00:10:42,510 We'll back to that list. 230 00:10:42,510 --> 00:10:52,550 231 00:10:52,550 --> 00:10:56,080 What about during practice quizzes, if people have taken those already? 232 00:10:56,080 --> 00:10:59,110 What were some problems that tripped you guys up? 233 00:10:59,110 --> 00:11:08,970 234 00:11:08,970 --> 00:11:12,720 I know for a fact that last year's quiz was really hard. 235 00:11:12,720 --> 00:11:15,670 >> AUDIENCE: Can you explain what an SQL injection attack is? 236 00:11:15,670 --> 00:11:18,970 >> JASON HIRSCHHORN: OK, great. 237 00:11:18,970 --> 00:11:20,440 So we talked about this a bit. 238 00:11:20,440 --> 00:11:22,050 There's a lecture on security. 239 00:11:22,050 --> 00:11:25,670 And again, as I mentioned earlier, this is an aside. 240 00:11:25,670 --> 00:11:30,010 But you will be frustrated on the quiz when you read some small two point 241 00:11:30,010 --> 00:11:33,040 question, and you're like, when did I ever learn that? 242 00:11:33,040 --> 00:11:35,560 >> All of those things in those lectures that you didn't think you needed to 243 00:11:35,560 --> 00:11:38,290 know, or you could gloss over because they didn't have to do with the 244 00:11:38,290 --> 00:11:41,860 problem set, those will likely come up again on the quiz. 245 00:11:41,860 --> 00:11:45,030 So, cool, fun things that you just thought David was telling for you to 246 00:11:45,030 --> 00:11:49,070 enjoy, he was telling you for you to enjoy and to make you just be super 247 00:11:49,070 --> 00:11:50,550 excited about learning everything there is to learn 248 00:11:50,550 --> 00:11:51,670 about computer science. 249 00:11:51,670 --> 00:11:53,680 Those things also come up on quizzes. 250 00:11:53,680 --> 00:11:56,440 So, even these small things that didn't directly relate to your problem 251 00:11:56,440 --> 00:11:59,630 set, as you guys are familiar with from Quiz 0, will probably come up. 252 00:11:59,630 --> 00:12:01,530 And this is a good example of something. 253 00:12:01,530 --> 00:12:10,140 >> So a SQL injection attacks is when you get some information from the user and 254 00:12:10,140 --> 00:12:15,090 you want to insert it into a table using a SQL insert statement, but you 255 00:12:15,090 --> 00:12:17,680 didn't sanitize the input ahead of time. 256 00:12:17,680 --> 00:12:21,560 So, obviously we've seen SQL statements. 257 00:12:21,560 --> 00:12:22,810 I'll just open up-- 258 00:12:22,810 --> 00:12:25,590 259 00:12:25,590 --> 00:12:26,840 let's go-- 260 00:12:26,840 --> 00:12:31,290 261 00:12:31,290 --> 00:12:31,960 we'll go to the review-- 262 00:12:31,960 --> 00:12:35,180 I think, who covered it? 263 00:12:35,180 --> 00:12:36,350 I think Samala did. 264 00:12:36,350 --> 00:12:39,292 So we can get-- 265 00:12:39,292 --> 00:12:41,270 >> AUDIENCE: Where did you find this? 266 00:12:41,270 --> 00:12:44,990 >> JASON HIRSCHHORN: So if you go to CS50.net, quizzes, and then you can 267 00:12:44,990 --> 00:12:47,170 scroll over and get slides from the review session. 268 00:12:47,170 --> 00:12:49,860 But you can see this is a good example of a SQL injection attack. 269 00:12:49,860 --> 00:12:53,690 We take some information from the user and they give us a string, and then we 270 00:12:53,690 --> 00:12:55,780 want to insert that string into a database. 271 00:12:55,780 --> 00:12:59,780 Generally we are going to sanitize that input, which means there are some 272 00:12:59,780 --> 00:13:01,050 characters that are dangerous. 273 00:13:01,050 --> 00:13:04,000 >> For example, in SQL strings, these quotes-- 274 00:13:04,000 --> 00:13:05,000 single quotes or double quotes-- 275 00:13:05,000 --> 00:13:05,620 mean something. 276 00:13:05,620 --> 00:13:08,380 They mean end this string here. 277 00:13:08,380 --> 00:13:13,090 And so if the user gives you a single or a double quote, they could be 278 00:13:13,090 --> 00:13:18,970 trying to trip up your SQL query and insert some bad stuff into it. 279 00:13:18,970 --> 00:13:23,130 And if they do that, they could gain control of your database or do some 280 00:13:23,130 --> 00:13:24,760 things that you don't want them to do. 281 00:13:24,760 --> 00:13:28,300 >> So that's why whenever we take SQL queries, we sanitize the input before 282 00:13:28,300 --> 00:13:31,090 putting it into the database, which means we escape those characters. 283 00:13:31,090 --> 00:13:32,590 We'll talk about that in a second. 284 00:13:32,590 --> 00:13:35,820 But long story short, a SQL injection attack is if you don't do that-- 285 00:13:35,820 --> 00:13:39,760 if you don't take care of the input they gave you before putting your 286 00:13:39,760 --> 00:13:46,830 database, they can, as you see down here, run a query that, in fact-- 287 00:13:46,830 --> 00:13:52,470 they put in their code down here and this select line down here will select 288 00:13:52,470 --> 00:13:56,360 everything from the table regardless of what the password is given. 289 00:13:56,360 --> 00:13:58,960 Because you have the or 1 equals 1. 290 00:13:58,960 --> 00:14:02,750 >> So it's basically, long story short, a way to take over the database. 291 00:14:02,750 --> 00:14:07,570 The question, then, for you guys, is where in p sets 7 did you sanitize all 292 00:14:07,570 --> 00:14:10,010 the inputs to your SQL queries? 293 00:14:10,010 --> 00:14:11,230 Where did that step happen? 294 00:14:11,230 --> 00:14:14,150 Where do you prevent SQL injection attacks from happening in p set 7? 295 00:14:14,150 --> 00:14:20,100 296 00:14:20,100 --> 00:14:20,490 Yeah. 297 00:14:20,490 --> 00:14:21,870 >> AUDIENCE: Crypt? 298 00:14:21,870 --> 00:14:23,120 >> JASON HIRSCHHORN: So it wasn't crypt. 299 00:14:23,120 --> 00:14:52,360 300 00:14:52,360 --> 00:14:55,380 We didn't make you do this for this particular problem set, but it happens 301 00:14:55,380 --> 00:14:58,190 in the query function. 302 00:14:58,190 --> 00:15:00,930 We actually wrote it for you, and we took care of the 303 00:15:00,930 --> 00:15:03,040 sanitizing inputs for you. 304 00:15:03,040 --> 00:15:07,790 But in years past, students have had to type the inputs on their own. 305 00:15:07,790 --> 00:15:10,020 In p set 7, a lot of you-- 306 00:15:10,020 --> 00:15:11,270 let me open up one other file. 307 00:15:11,270 --> 00:15:18,530 308 00:15:18,530 --> 00:15:22,590 >> So you'll notice up here a lot of people, in problem set 7, did not call 309 00:15:22,590 --> 00:15:25,240 this function on strings. 310 00:15:25,240 --> 00:15:27,880 This function, htmlspecialchars, again-- 311 00:15:27,880 --> 00:15:31,410 this string might have some things that in HTML mean something else. 312 00:15:31,410 --> 00:15:36,160 Like a brace, a square, or an angle bracket mean something in HTML. 313 00:15:36,160 --> 00:15:38,980 >> And so if you print that out to the screen or if you just take that and 314 00:15:38,980 --> 00:15:42,260 print that out to your HTML, that might do something you don't expect. 315 00:15:42,260 --> 00:15:45,180 So htmlspecialchars goes over all those characters that have special 316 00:15:45,180 --> 00:15:47,030 meeting and escapes them. 317 00:15:47,030 --> 00:15:51,450 So it gets printed out as the text you want to see, rather than 318 00:15:51,450 --> 00:15:53,280 screwing up your HTML. 319 00:15:53,280 --> 00:15:55,040 We called that function in the header. 320 00:15:55,040 --> 00:15:57,390 And a lot of people forgot to call that function in the 321 00:15:57,390 --> 00:15:58,700 code you were writing. 322 00:15:58,700 --> 00:16:03,970 >> So, for example, if a stock name had an angle bracket in it and you forgot 323 00:16:03,970 --> 00:16:06,675 to call this function, that angle bracket could have thrown off what 324 00:16:06,675 --> 00:16:08,250 your HTML looked like. 325 00:16:08,250 --> 00:16:11,810 But calling this function will escape that so it actually prints out as an 326 00:16:11,810 --> 00:16:15,870 angle bracket and doesn't throw off your HTML code. 327 00:16:15,870 --> 00:16:18,760 >> The same reason we've seen, sometimes, slashes before double quotes in a 328 00:16:18,760 --> 00:16:22,310 printf line because we don't want the double quotes down the string. 329 00:16:22,310 --> 00:16:24,050 We want to print them out to the screen. 330 00:16:24,050 --> 00:16:26,920 So all of this is the same idea. 331 00:16:26,920 --> 00:16:28,260 Does that answer your question? 332 00:16:28,260 --> 00:16:31,529 333 00:16:31,529 --> 00:16:33,870 >> AUDIENCE: Kind of. 334 00:16:33,870 --> 00:16:35,300 >> JASON HIRSCHHORN: Do you have a follow-up? 335 00:16:35,300 --> 00:16:43,252 >> AUDIENCE: I guess the SQL injection attack has to do with that? 336 00:16:43,252 --> 00:16:45,720 I don't understand how the two are related. 337 00:16:45,720 --> 00:16:47,610 Why would you do the specialchars? 338 00:16:47,610 --> 00:16:51,200 >> JASON HIRSCHHORN: OK, so the SQL injection attack is when you inject 339 00:16:51,200 --> 00:16:59,180 some malicious strings into somebody's program, and they just take it and run 340 00:16:59,180 --> 00:17:01,230 the SQL query with a string you gave them. 341 00:17:01,230 --> 00:17:04,220 As you can see down here, that could be problematic. 342 00:17:04,220 --> 00:17:07,480 So the way you prevent against that is you take their string that they give 343 00:17:07,480 --> 00:17:09,220 you-- so this string right here-- 344 00:17:09,220 --> 00:17:11,240 and you sanitize it. 345 00:17:11,240 --> 00:17:14,305 You escape all the things that are potentially problematic. 346 00:17:14,305 --> 00:17:18,626 So you don't interpret them as something that means something. 347 00:17:18,626 --> 00:17:23,390 >> And an example of that with HTML is this function. 348 00:17:23,390 --> 00:17:26,060 So it's the same idea here. 349 00:17:26,060 --> 00:17:27,579 And I was just showing you other examples of when you've 350 00:17:27,579 --> 00:17:29,030 seen this idea before. 351 00:17:29,030 --> 00:17:33,913 Of escaping user input before printing it out to a screen or putting it 352 00:17:33,913 --> 00:17:36,782 inside a SQL statement. 353 00:17:36,782 --> 00:17:40,790 >> AUDIENCE: So in this case, the user is messing with the programmer. 354 00:17:40,790 --> 00:17:41,240 >> JASON HIRSCHHORN: Yes. 355 00:17:41,240 --> 00:17:44,800 With all of these security attacks, that's always generally the user, or 356 00:17:44,800 --> 00:17:47,470 somebody, is trying to mess with you, the programmer. 357 00:17:47,470 --> 00:17:51,038 And these are ways you can prevent against them. 358 00:17:51,038 --> 00:17:54,280 >> AUDIENCE: So I have a question about hash functions. 359 00:17:54,280 --> 00:17:59,340 In Quiz 1 from 2011, there are two questions about one-sided hashes. 360 00:17:59,340 --> 00:18:02,540 And I was just wondering what that meant. 361 00:18:02,540 --> 00:18:03,660 >> JASON HIRSCHHORN: OK, which quiz? 362 00:18:03,660 --> 00:18:03,770 2011? 363 00:18:03,770 --> 00:18:04,705 >> AUDIENCE: Yeah. 364 00:18:04,705 --> 00:18:06,720 >> AUDIENCE: Quiz 1? 365 00:18:06,720 --> 00:18:08,620 >> AUDIENCE: [INAUDIBLE]. 366 00:18:08,620 --> 00:18:09,940 That's like hashing a password. 367 00:18:09,940 --> 00:18:12,220 That's not putting things-- 368 00:18:12,220 --> 00:18:13,440 >> JASON HIRSCHHORN: What page was it? 369 00:18:13,440 --> 00:18:15,720 >> AUDIENCE: I think it was 9 or 10, or both. 370 00:18:15,720 --> 00:18:16,720 >> JASON HIRSCHHORN: All right, go ahead, Curt. 371 00:18:16,720 --> 00:18:17,780 You can answer while we look. 372 00:18:17,780 --> 00:18:19,540 >> AUDIENCE: I think it's talking about hashing a password. 373 00:18:19,540 --> 00:18:24,430 Like, when someone enters a password, you turn it into an encrypted thing. 374 00:18:24,430 --> 00:18:27,395 That's the password hash, which is different from a hash function that 375 00:18:27,395 --> 00:18:30,900 puts something into a hash table. 376 00:18:30,900 --> 00:18:31,610 >> JASON HIRSCHHORN: Let's see. 377 00:18:31,610 --> 00:18:33,930 Let me pull up what they give as the answer. 378 00:18:33,930 --> 00:18:35,440 And then we'll walk through it. 379 00:18:35,440 --> 00:18:42,430 380 00:18:42,430 --> 00:18:45,400 >> So Curt gave a great example of a one-way hash. 381 00:18:45,400 --> 00:18:48,800 When we've seen this before, we take the password and turn-- 382 00:18:48,800 --> 00:18:53,040 remember, in p set 7, somebody might have a password that's just password, 383 00:18:53,040 --> 00:18:55,300 but then it gets encrypted into some really long thing. 384 00:18:55,300 --> 00:18:59,830 The one-way hash means it is very easy to go from one way to the other, but 385 00:18:59,830 --> 00:19:02,800 it's very hard to go from the other way back. 386 00:19:02,800 --> 00:19:05,230 >> And so you know, when you were checking people's passwords in problem 387 00:19:05,230 --> 00:19:08,820 set 7, you would take their-- 388 00:19:08,820 --> 00:19:11,953 so, for example, say they wanted to change their password, you ask them 389 00:19:11,953 --> 00:19:13,130 for their old password. 390 00:19:13,130 --> 00:19:13,910 You took their old password. 391 00:19:13,910 --> 00:19:15,150 You encrypted it. 392 00:19:15,150 --> 00:19:19,240 And then compared the two encryptions rather than unencrypting the original 393 00:19:19,240 --> 00:19:20,780 one, because it's really hard to go that way. 394 00:19:20,780 --> 00:19:27,070 395 00:19:27,070 --> 00:19:28,035 Yeah. 396 00:19:28,035 --> 00:19:31,430 >> AUDIENCE: How in depth does our understanding of TelNet have to be? 397 00:19:31,430 --> 00:19:34,870 398 00:19:34,870 --> 00:19:41,360 >> JASON HIRSCHHORN: If it was mentioned briefly in lecture, just a brief 399 00:19:41,360 --> 00:19:43,260 understanding. 400 00:19:43,260 --> 00:19:45,585 Again, back to the answer to Avi's question-- 401 00:19:45,585 --> 00:19:48,260 402 00:19:48,260 --> 00:19:50,430 the more things come up, the more likely it is you have to be super 403 00:19:50,430 --> 00:19:51,530 familiar with them. 404 00:19:51,530 --> 00:19:54,730 If they've only come up in lecture, that's just one place. 405 00:19:54,730 --> 00:19:57,180 But if they come up in lecture, section, and a problem set, then you 406 00:19:57,180 --> 00:19:58,710 probably have to be super familiar with them. 407 00:19:58,710 --> 00:20:01,320 408 00:20:01,320 --> 00:20:03,960 >> So I had a question from earlier about-- 409 00:20:03,960 --> 00:20:06,950 is was fall 2010-- 410 00:20:06,950 --> 00:20:08,520 Quiz 1, let's pull up-- 411 00:20:08,520 --> 00:20:17,390 412 00:20:17,390 --> 00:20:21,790 this question on stacks and queues, which we did spend a fair bit of time 413 00:20:21,790 --> 00:20:23,720 talking about in lecture, even though we didn't really 414 00:20:23,720 --> 00:20:26,020 ever hit it in section. 415 00:20:26,020 --> 00:20:33,190 So this question is giving you a series of commands and asking you what 416 00:20:33,190 --> 00:20:35,560 gets printed in this case. 417 00:20:35,560 --> 00:20:40,180 So this is a totally reasonable question that could be asked of you 418 00:20:40,180 --> 00:20:43,090 guys, and then you guys should be able to answer it. 419 00:20:43,090 --> 00:20:50,020 >> So why don't you look at it for 30 seconds, and then if anybody wants to 420 00:20:50,020 --> 00:20:52,140 propose the answers to me, and then we'll walk through it. 421 00:20:52,140 --> 00:21:22,590 422 00:21:22,590 --> 00:21:24,235 All right, who has an answer to question 27? 423 00:21:24,235 --> 00:21:31,740 424 00:21:31,740 --> 00:21:33,860 Yeah. 425 00:21:33,860 --> 00:21:40,250 >> AUDIENCE: Is it 1, 2, 3, 3? 426 00:21:40,250 --> 00:21:40,780 >> JASON HIRSCHHORN: That's right. 427 00:21:40,780 --> 00:21:42,570 27 is 1, 2, 3, 3. 428 00:21:42,570 --> 00:21:44,510 So let's look at how we got that. 429 00:21:44,510 --> 00:21:48,930 >> First, we are saying, if s is a queue, what gets printed? 430 00:21:48,930 --> 00:21:53,360 So a q is first in, first out. 431 00:21:53,360 --> 00:21:54,680 We've seen that before. 432 00:21:54,680 --> 00:21:56,820 We saw the picture of the people waiting at the Apple 433 00:21:56,820 --> 00:21:58,400 Store to buy some product. 434 00:21:58,400 --> 00:22:00,900 The first people in are the first people out. 435 00:22:00,900 --> 00:22:02,940 The first things in a queue are the first things out. 436 00:22:02,940 --> 00:22:08,320 >> So if we push something into a queue, you push the 1, then we pop the 1. 437 00:22:08,320 --> 00:22:09,630 Pop just means take out. 438 00:22:09,630 --> 00:22:11,080 In this case, just take something out. 439 00:22:11,080 --> 00:22:12,910 We take out the first thing, that's a 1. 440 00:22:12,910 --> 00:22:15,200 So we'll put things we print down over here. 441 00:22:15,200 --> 00:22:18,110 This is no longer in our queue. 442 00:22:18,110 --> 00:22:23,500 >> Then we push on a 2 and a 3, and we pop off the first thing. 443 00:22:23,500 --> 00:22:25,030 Again, because it's a queue. 444 00:22:25,030 --> 00:22:33,320 So we get a 2, then we put on another 3 and call pop again. 445 00:22:33,320 --> 00:22:34,980 Our 3 is first. 446 00:22:34,980 --> 00:22:40,940 >> And then we had a whole bunch of other things and call pop. 447 00:22:40,940 --> 00:22:43,740 But again, since this is a queue, first in, first out. 448 00:22:43,740 --> 00:22:45,980 We take out the first thing that was ever put in. 449 00:22:45,980 --> 00:22:47,100 That's our 3. 450 00:22:47,100 --> 00:22:50,060 And, in this case, we don't worry about all those other things. 451 00:22:50,060 --> 00:22:51,310 So that's if this is a queue. 452 00:22:51,310 --> 00:22:58,917 453 00:22:58,917 --> 00:23:00,167 Any questions about a queue? 454 00:23:00,167 --> 00:23:03,290 455 00:23:03,290 --> 00:23:04,040 >> A stack's different. 456 00:23:04,040 --> 00:23:07,782 What is the acronym we have for understanding a stack? 457 00:23:07,782 --> 00:23:08,750 >> AUDIENCE: Last in, first out. 458 00:23:08,750 --> 00:23:10,130 >> JASON HIRSCHHORN: LIFO, I think. 459 00:23:10,130 --> 00:23:11,830 Last in, first out. 460 00:23:11,830 --> 00:23:15,630 So we saw an example of a stack of trays in a dining hall. 461 00:23:15,630 --> 00:23:17,590 Whatever tray is on top gets picked up. 462 00:23:17,590 --> 00:23:19,550 And then if new trays come in, they get put on top. 463 00:23:19,550 --> 00:23:21,070 And then whatever is on top gets picked up. 464 00:23:21,070 --> 00:23:24,010 So those trays on the bottom might stay there for awhile. 465 00:23:24,010 --> 00:23:28,480 >> In that case, again, we'll draw this out. 466 00:23:28,480 --> 00:23:31,770 We push on one, so one is first in line. 467 00:23:31,770 --> 00:23:32,790 And we pop something off. 468 00:23:32,790 --> 00:23:37,280 And there's only one thing in there, so we move 1 down here. 469 00:23:37,280 --> 00:23:41,940 Then we put on 2 and 3 and we pop something off. 470 00:23:41,940 --> 00:23:43,650 >> But again, since this is a queue-- 471 00:23:43,650 --> 00:23:45,010 or this is a stack, rather-- 472 00:23:45,010 --> 00:23:47,480 we take whatever was in last. 473 00:23:47,480 --> 00:23:49,300 Whatever is in last comes out first. 474 00:23:49,300 --> 00:23:50,890 And 3 is in last. 475 00:23:50,890 --> 00:23:56,110 So we put the 3 down there, then we put on another 3 and we 476 00:23:56,110 --> 00:23:57,360 pop something again. 477 00:23:57,360 --> 00:23:59,990 478 00:23:59,990 --> 00:24:05,710 Finally, we put on the 4, 5, 6, and 7, and here we pop. 479 00:24:05,710 --> 00:24:09,060 And because it's a stack, we take whatever was put in last and write 480 00:24:09,060 --> 00:24:10,240 that down here. 481 00:24:10,240 --> 00:24:14,256 So we end up with 1, 3, 3, 7. 482 00:24:14,256 --> 00:24:17,380 483 00:24:17,380 --> 00:24:21,380 Does anybody have any questions about stacks or queues, or this example? 484 00:24:21,380 --> 00:24:27,540 485 00:24:27,540 --> 00:24:29,030 >> OK. 486 00:24:29,030 --> 00:24:30,440 Let's go back to the list of topics. 487 00:24:30,440 --> 00:24:32,510 Not that way, this way. 488 00:24:32,510 --> 00:24:34,280 What other questions do people have? 489 00:24:34,280 --> 00:24:37,550 490 00:24:37,550 --> 00:24:39,480 >> AUDIENCE: I don't know how important this is, but I was confused by the 491 00:24:39,480 --> 00:24:43,550 difference between different types of languages like markup, compiled, 492 00:24:43,550 --> 00:24:45,980 interpreted. 493 00:24:45,980 --> 00:24:46,750 >> JASON HIRSCHHORN: That's a good question. 494 00:24:46,750 --> 00:24:50,500 I think that is somewhat important, so let's go over it quickly. 495 00:24:50,500 --> 00:24:56,850 The big languages we've seen so far are C, PHP, and JavaScript, in terms 496 00:24:56,850 --> 00:24:58,330 of programming languages. 497 00:24:58,330 --> 00:25:01,060 HTML, as you mentioned, is not a programming language. 498 00:25:01,060 --> 00:25:02,260 It's a markup language. 499 00:25:02,260 --> 00:25:05,700 And then we have CSS, which is also not a programming language. 500 00:25:05,700 --> 00:25:10,330 >> We've also seen SQL, which is not a programming language either. 501 00:25:10,330 --> 00:25:15,695 So SQL allows you to write queries for a database. 502 00:25:15,695 --> 00:25:18,370 503 00:25:18,370 --> 00:25:20,140 HTML is a markup language. 504 00:25:20,140 --> 00:25:22,570 It defines how things are structured. 505 00:25:22,570 --> 00:25:26,250 And CSS allows you to style things. 506 00:25:26,250 --> 00:25:28,520 That's probably the extent for what you need to know about those three. 507 00:25:28,520 --> 00:25:32,920 But it is more interesting to figure out the differences between C, PHP, 508 00:25:32,920 --> 00:25:34,320 and JavaScript. 509 00:25:34,320 --> 00:25:37,900 >> So one of the biggest differences, as you mentioned, is how they're 510 00:25:37,900 --> 00:25:40,550 compiled, or whatever the equivalent is. 511 00:25:40,550 --> 00:25:42,580 So C is compiled. 512 00:25:42,580 --> 00:25:43,950 We would always run a compiler. 513 00:25:43,950 --> 00:25:51,100 And then where are your errors when you run the C compiler? 514 00:25:51,100 --> 00:25:55,740 Where does it show you the errors In your code? 515 00:25:55,740 --> 00:25:57,860 How do you know there's an error in your code in C? 516 00:25:57,860 --> 00:25:58,770 >> AUDIENCE: It shows you in the terminal. 517 00:25:58,770 --> 00:26:00,410 >> JASON HIRSCHHORN: It shows you in the terminal as you're compiling. 518 00:26:00,410 --> 00:26:02,620 And if there are errors, it won't actually compile it. 519 00:26:02,620 --> 00:26:04,830 So you know that there are errors right away, ahead of time, before you 520 00:26:04,830 --> 00:26:06,050 even run your code. 521 00:26:06,050 --> 00:26:10,010 >> Of course, you might run your code and get a segmentation fault, but that was 522 00:26:10,010 --> 00:26:12,350 probably because you did some silly logic thing. 523 00:26:12,350 --> 00:26:15,770 But your code with technically all correct and could run. 524 00:26:15,770 --> 00:26:18,210 So C code gets compiled ahead of time. 525 00:26:18,210 --> 00:26:19,760 What about PHP code? 526 00:26:19,760 --> 00:26:21,430 Where were errors in your PHP code? 527 00:26:21,430 --> 00:26:23,170 How did you know you had errors in your PHP code? 528 00:26:23,170 --> 00:26:26,038 529 00:26:26,038 --> 00:26:28,430 >> AUDIENCE: Run time? 530 00:26:28,430 --> 00:26:31,230 >> JASON HIRSCHHORN: Yeah, when you would run it, you would run the 531 00:26:31,230 --> 00:26:32,180 PHP code in the back. 532 00:26:32,180 --> 00:26:33,300 And then you would display a screen. 533 00:26:33,300 --> 00:26:35,260 You might see some things on the top, but then you would see, like, some 534 00:26:35,260 --> 00:26:36,710 orange, ugly table. 535 00:26:36,710 --> 00:26:41,420 And it would give you a line number and say, blah, blah, blah, this stuff 536 00:26:41,420 --> 00:26:42,400 didn't work. 537 00:26:42,400 --> 00:26:48,730 >> So PHP is interpreted line by line and executed on the server. 538 00:26:48,730 --> 00:26:52,380 And then the result is sent over to you. 539 00:26:52,380 --> 00:26:53,340 Great. 540 00:26:53,340 --> 00:26:56,410 Executed in the server line by line and then sent over to you. 541 00:26:56,410 --> 00:26:59,010 And if there's an error, it'll send you the error, but you might have 542 00:26:59,010 --> 00:27:00,400 gotten some stuff ahead of time. 543 00:27:00,400 --> 00:27:02,730 So some of it might have worked, but later on, some stuff might not have 544 00:27:02,730 --> 00:27:03,890 not worked. 545 00:27:03,890 --> 00:27:04,600 >> What about JavaScript? 546 00:27:04,600 --> 00:27:06,065 Where did you see JavaScript errors? 547 00:27:06,065 --> 00:27:10,860 548 00:27:10,860 --> 00:27:12,870 In p set 8, when you got an error, how did you know? 549 00:27:12,870 --> 00:27:13,710 Where would it show up? 550 00:27:13,710 --> 00:27:15,900 >> AUDIENCE: In the console, at the bottom. 551 00:27:15,900 --> 00:27:17,650 >> JASON HIRSCHHORN: In the console, on the bottom. 552 00:27:17,650 --> 00:27:20,160 It would also give you the line number, and it would 553 00:27:20,160 --> 00:27:21,330 show up on the bottom. 554 00:27:21,330 --> 00:27:24,320 And JavaScript was not executed on the server. 555 00:27:24,320 --> 00:27:27,800 JavaScript was sent to your computer, and then when it was time to run the 556 00:27:27,800 --> 00:27:31,670 JavaScript, the JavaScript was run line by line on the 557 00:27:31,670 --> 00:27:33,410 client, on your side. 558 00:27:33,410 --> 00:27:35,570 Not the server, the client side. 559 00:27:35,570 --> 00:27:37,690 >> And similarly, it was run line by line. 560 00:27:37,690 --> 00:27:40,630 And then when you would get an error, it would show up at the bottom. 561 00:27:40,630 --> 00:27:44,580 Similarly to PHP, some of it might execute, and then you might get an 562 00:27:44,580 --> 00:27:46,310 error later on. 563 00:27:46,310 --> 00:27:49,910 >> Also, a little unlike PHP, if you got a JavaScript error-- 564 00:27:49,910 --> 00:27:52,780 say you didn't do the right code for an alert box-- 565 00:27:52,780 --> 00:27:55,800 you could keep running your program. 566 00:27:55,800 --> 00:27:58,180 The alert box wouldn't work, but your program would be fine. 567 00:27:58,180 --> 00:28:00,490 Just maybe that function would fail. 568 00:28:00,490 --> 00:28:02,610 >> So there's some of the biggest difference in terms of how these 569 00:28:02,610 --> 00:28:09,230 languages, or how the programming code you write are actually evaluated. 570 00:28:09,230 --> 00:28:11,970 There are also other differences in terms of-- the biggest difference 571 00:28:11,970 --> 00:28:15,590 we've seen in terms of variables in the different languages. 572 00:28:15,590 --> 00:28:19,660 So can anybody give me a difference between variables 573 00:28:19,660 --> 00:28:20,910 in the three languages? 574 00:28:20,910 --> 00:28:24,802 575 00:28:24,802 --> 00:28:25,770 Yes. 576 00:28:25,770 --> 00:28:27,130 >> AUDIENCE: In C, they're strictly typed. 577 00:28:27,130 --> 00:28:28,550 In the other two, they're loosely typed. 578 00:28:28,550 --> 00:28:30,040 >> JASON HIRSCHHORN: And what does that mean? 579 00:28:30,040 --> 00:28:31,775 >> AUDIENCE: That in C, you have to declare the type of the variable when 580 00:28:31,775 --> 00:28:36,140 you declare the variable, like interbool or char. 581 00:28:36,140 --> 00:28:36,990 >> JASON HIRSCHHORN: Excellent. 582 00:28:36,990 --> 00:28:39,780 In C, we always had to put a type of a variable. 583 00:28:39,780 --> 00:28:41,360 And we couldn't really mix types. 584 00:28:41,360 --> 00:28:45,750 You couldn't do an integer plus a string. 585 00:28:45,750 --> 00:28:48,760 But as we've seen in these other languages, you actually can mix types, 586 00:28:48,760 --> 00:28:51,230 and you never really have to give something a type, ever. 587 00:28:51,230 --> 00:28:53,905 >> So how do we know things are variables in PHP and JavaScript? 588 00:28:53,905 --> 00:28:57,120 589 00:28:57,120 --> 00:28:58,685 >> AUDIENCE: In PHP, they start with a dollar sign. 590 00:28:58,685 --> 00:29:00,810 In JavaScript, when you declare them, you have to have a bar. 591 00:29:00,810 --> 00:29:01,760 >> JASON HIRSCHHORN: Right. 592 00:29:01,760 --> 00:29:03,535 So in PHP, they start with a dollar sign. 593 00:29:03,535 --> 00:29:06,300 In JavaScript, they have to have bar, although sometimes they don't actually 594 00:29:06,300 --> 00:29:07,520 have to have bar. 595 00:29:07,520 --> 00:29:09,240 But that's correct. 596 00:29:09,240 --> 00:29:13,300 >> So that's a big difference between variables. 597 00:29:13,300 --> 00:29:16,140 I think those are probably, off the top of my head, the two biggest 598 00:29:16,140 --> 00:29:19,250 differences between these three languages. 599 00:29:19,250 --> 00:29:20,594 But, yeah. 600 00:29:20,594 --> 00:29:24,720 >> AUDIENCE: And the scope of C variables is restricted to the curly braces, 601 00:29:24,720 --> 00:29:27,760 where the other ones, it's just like, it dies if it's in a function only, 602 00:29:27,760 --> 00:29:29,650 but otherwise, it's-- 603 00:29:29,650 --> 00:29:30,240 >> JASON HIRSCHHORN: Right. 604 00:29:30,240 --> 00:29:36,780 So scope is slightly different in C. As you remember, curly braces define 605 00:29:36,780 --> 00:29:37,710 the scope of variables. 606 00:29:37,710 --> 00:29:41,680 So if it was defined inside an if condition, which is inside a for loop, 607 00:29:41,680 --> 00:29:44,290 the variable only exists there. 608 00:29:44,290 --> 00:29:47,760 >> In JavaScript, if a variable is defined inside an if condition-- 609 00:29:47,760 --> 00:29:50,750 inside a for loop-- it'll exist for that function, but it won't exist 610 00:29:50,750 --> 00:29:52,330 outside that function. 611 00:29:52,330 --> 00:29:59,250 So scope is a little bit more flexible in JavaScript and PHP. 612 00:29:59,250 --> 00:30:00,500 That answer the question? 613 00:30:00,500 --> 00:30:03,110 614 00:30:03,110 --> 00:30:04,635 OK, any other questions? 615 00:30:04,635 --> 00:30:07,260 616 00:30:07,260 --> 00:30:08,865 We can do four more minutes of questions, then 617 00:30:08,865 --> 00:30:10,740 we'll jump into coding. 618 00:30:10,740 --> 00:30:12,645 >> AUDIENCE: Can we go into Ajax and talk about what that is? 619 00:30:12,645 --> 00:30:15,670 620 00:30:15,670 --> 00:30:17,800 >> JASON HIRSCHHORN: Talk to Avi after. 621 00:30:17,800 --> 00:30:19,170 He asked that question earlier. 622 00:30:19,170 --> 00:30:19,630 >> AUDIENCE: My bad. 623 00:30:19,630 --> 00:30:20,880 >> JASON HIRSCHHORN: No worries. 624 00:30:20,880 --> 00:30:22,740 625 00:30:22,740 --> 00:30:24,290 >> AUDIENCE: What exactly is JSON? 626 00:30:24,290 --> 00:30:28,360 627 00:30:28,360 --> 00:30:28,900 >> JASON HIRSCHHORN: What is JSON? 628 00:30:28,900 --> 00:30:29,930 What's your question? 629 00:30:29,930 --> 00:30:31,350 >> AUDIENCE: Just really quickly, the difference between 630 00:30:31,350 --> 00:30:32,870 print and echo in PHP. 631 00:30:32,870 --> 00:30:36,200 632 00:30:36,200 --> 00:30:38,490 >> JASON HIRSCHHORN: Why don't you google the difference between print and echo? 633 00:30:38,490 --> 00:30:40,670 Slight difference. 634 00:30:40,670 --> 00:30:42,020 Not that big of a deal. 635 00:30:42,020 --> 00:30:44,960 But you should definitely google it, and that'll give you a good answer. 636 00:30:44,960 --> 00:30:46,910 >> JSON, probably bigger of a deal. 637 00:30:46,910 --> 00:30:49,300 Stands for JavaScript Object Notation. 638 00:30:49,300 --> 00:30:51,865 And when have we seen JSON being used? 639 00:30:51,865 --> 00:30:55,110 640 00:30:55,110 --> 00:30:55,900 When have you seen-- 641 00:30:55,900 --> 00:30:57,400 why do you even know the word JSON? 642 00:30:57,400 --> 00:30:59,140 When have you seen it? 643 00:30:59,140 --> 00:31:02,200 >> AUDIENCE: When we were getting stock quotes for finance. 644 00:31:02,200 --> 00:31:02,690 >> JASON HIRSCHHORN: So you saw it when you were getting 645 00:31:02,690 --> 00:31:04,830 stock quotes for finance. 646 00:31:04,830 --> 00:31:07,340 And why did you see it? 647 00:31:07,340 --> 00:31:09,000 >> AUDIENCE: When we were retrieving all the information that 648 00:31:09,000 --> 00:31:10,400 came in that format. 649 00:31:10,400 --> 00:31:11,700 >> JASON HIRSCHHORN: So you would get-- 650 00:31:11,700 --> 00:31:12,540 yeah. 651 00:31:12,540 --> 00:31:13,020 Go ahead. 652 00:31:13,020 --> 00:31:15,210 >> AUDIENCE: [INAUDIBLE] information out of an object? 653 00:31:15,210 --> 00:31:17,170 >> JASON HIRSCHHORN: Both of those put together is the answer 654 00:31:17,170 --> 00:31:18,100 we're looking for. 655 00:31:18,100 --> 00:31:21,240 You want information from this other webpage. 656 00:31:21,240 --> 00:31:23,790 And you would hope that when you're getting that information, it would be 657 00:31:23,790 --> 00:31:26,720 presented to you in some type of standardized format. 658 00:31:26,720 --> 00:31:29,530 >> Everybody is probably familiar with comma-separated values. 659 00:31:29,530 --> 00:31:32,970 You can export an Excel spreadsheet or any type of spreadsheet as a list of 660 00:31:32,970 --> 00:31:34,540 comma-separated values. 661 00:31:34,540 --> 00:31:37,370 And the commas divide all the different fields. 662 00:31:37,370 --> 00:31:38,780 JavaScript Object Notation-- 663 00:31:38,780 --> 00:31:39,440 JSON-- 664 00:31:39,440 --> 00:31:43,540 is another type of standardized layout of things. 665 00:31:43,540 --> 00:31:49,010 And that's often how we retrieve information from our Ajax queries. 666 00:31:49,010 --> 00:31:51,770 >> So in this case, we got it from the Yahoo site. 667 00:31:51,770 --> 00:31:53,600 They return things to us in a JSON object. 668 00:31:53,600 --> 00:31:56,790 And then we know, because it's a standard, what it's 669 00:31:56,790 --> 00:31:57,250 going to look like. 670 00:31:57,250 --> 00:32:00,760 So we can iterate through the array that's returned to us, the array of 671 00:32:00,760 --> 00:32:03,180 objects that are returned to us. 672 00:32:03,180 --> 00:32:07,770 >> We do probably need to know the keys, but they generally give you 673 00:32:07,770 --> 00:32:11,370 documentation in the website when you're fetching some JSON 674 00:32:11,370 --> 00:32:12,170 notation for them. 675 00:32:12,170 --> 00:32:16,940 Likewise, you can JSON encode an object. 676 00:32:16,940 --> 00:32:19,900 So there's a function JSON underscore encode. 677 00:32:19,900 --> 00:32:22,970 And so you can take an object that you've created, JSON encode it, and 678 00:32:22,970 --> 00:32:26,390 pass it on to something else, if you want to. 679 00:32:26,390 --> 00:32:30,770 And JSON decode also exists for a similar purpose, or for 680 00:32:30,770 --> 00:32:31,780 the opposite purpose. 681 00:32:31,780 --> 00:32:36,570 >> AUDIENCE: Do we need to know coding for hash tables and tries? 682 00:32:36,570 --> 00:32:40,300 Or do we just need to understand how they're used, conceptually? 683 00:32:40,300 --> 00:32:44,570 >> JASON HIRSCHHORN: So, raise your hand if you did a hash table for p set 4 684 00:32:44,570 --> 00:32:46,920 with a link list. 685 00:32:46,920 --> 00:32:47,960 Or p set 5. 686 00:32:47,960 --> 00:32:49,060 So that was a vast majority of people. 687 00:32:49,060 --> 00:32:50,390 P set 5, 6, who knows. 688 00:32:50,390 --> 00:32:51,240 A long time ago. 689 00:32:51,240 --> 00:32:54,140 >> So the vast majority of you did hash tables with link lists. 690 00:32:54,140 --> 00:32:56,525 And because that's probably the more common approach, and because we spent 691 00:32:56,525 --> 00:32:59,460 a lot of time doing link lists and hash tables, you should probably be 692 00:32:59,460 --> 00:33:02,600 pretty familiar with how to code a hash table and a link list. 693 00:33:02,600 --> 00:33:05,060 >> And if you think back to that problem set, it wasn't really 694 00:33:05,060 --> 00:33:06,410 as hard as you expected. 695 00:33:06,410 --> 00:33:08,120 And there was a lot less code than you expected. 696 00:33:08,120 --> 00:33:11,150 697 00:33:11,150 --> 00:33:14,650 I would say you should know how to code a hash table or a link list. 698 00:33:14,650 --> 00:33:17,010 Not that you'd be asked that, necessarily, but you should 699 00:33:17,010 --> 00:33:19,730 certainly know that. 700 00:33:19,730 --> 00:33:21,860 >> Also, if you look through past quizzes, there have been a lot of 701 00:33:21,860 --> 00:33:26,450 questions about writing functions on link lists or doubly-linked lists. 702 00:33:26,450 --> 00:33:28,370 That seems to come up every single year. 703 00:33:28,370 --> 00:33:31,940 Right insert on a link list, right delete from a link list, right insert 704 00:33:31,940 --> 00:33:33,610 for a doubly-linked list, et cetera. 705 00:33:33,610 --> 00:33:36,170 So that, I feel pretty comfortable saying you should know that. 706 00:33:36,170 --> 00:33:40,600 >> For try, I would say you should certainly know how it works, and maybe 707 00:33:40,600 --> 00:33:43,570 give some pseudocode for how to code it and set it up. 708 00:33:43,570 --> 00:33:45,600 But it would not be the worst thing in the world if you didn't know how to 709 00:33:45,600 --> 00:33:48,870 code it in C. It would be great if you knew how to code it in C, but I think 710 00:33:48,870 --> 00:33:52,516 probably pseudocode for a try would be the most you would need 711 00:33:52,516 --> 00:33:53,270 to know for a try. 712 00:33:53,270 --> 00:33:53,930 >> AUDIENCE: Extra credit? 713 00:33:53,930 --> 00:33:58,290 >> JASON HIRSCHHORN: And same with, if we go into binary search trees, you might 714 00:33:58,290 --> 00:34:02,320 need-- and you've seen in the past, we've done a lot of-- you know how 715 00:34:02,320 --> 00:34:03,380 binary search tree works. 716 00:34:03,380 --> 00:34:07,150 You should probably be able to set one up in pseudo code. 717 00:34:07,150 --> 00:34:10,510 But because the vast majority of people didn't do that on the problem 718 00:34:10,510 --> 00:34:13,880 set, I'd say it's probably less important that you know how to code 719 00:34:13,880 --> 00:34:17,380 and set up a tree like that. 720 00:34:17,380 --> 00:34:19,679 >> Any other questions? 721 00:34:19,679 --> 00:34:23,234 Also, we can ask them throughout as we go through some problems. 722 00:34:23,234 --> 00:34:27,170 OK, we're going to move on. 723 00:34:27,170 --> 00:34:28,230 Skip that slide for now. 724 00:34:28,230 --> 00:34:32,449 >> Speaking of trees, that is the first question I have for you guys. 725 00:34:32,449 --> 00:34:34,270 Because this is a problem. 726 00:34:34,270 --> 00:34:37,380 I would say it's highly likely you'll get a problem like this on your quiz 727 00:34:37,380 --> 00:34:43,659 asking you to code some type of insert, delete, search, for one type 728 00:34:43,659 --> 00:34:45,270 of data structure we've seen. 729 00:34:45,270 --> 00:34:47,719 >> That comes up every year and we spent a lot of time the second half of this 730 00:34:47,719 --> 00:34:50,270 semester going over these data types. 731 00:34:50,270 --> 00:34:54,170 So right now, I've defined a node in a binary search tree. 732 00:34:54,170 --> 00:34:58,490 And what I would like you to do is given a binary search tree that starts 733 00:34:58,490 --> 00:35:05,450 at this node star root, complete the implementation of the function below, 734 00:35:05,450 --> 00:35:07,430 which happens to be a find function. 735 00:35:07,430 --> 00:35:09,260 And do it with and without recursions. 736 00:35:09,260 --> 00:35:10,860 >> So I want you to write two functions. 737 00:35:10,860 --> 00:35:14,310 One doing this with recursion, one doing this without recursion. 738 00:35:14,310 --> 00:35:18,050 And do not assume that the root will be non-null. 739 00:35:18,050 --> 00:35:21,790 So we're looking for the integer i in the tree starting at root, and we need 740 00:35:21,790 --> 00:35:25,280 to write this recursively and iteratively. 741 00:35:25,280 --> 00:35:26,300 Yeah. 742 00:35:26,300 --> 00:35:29,730 >> AUDIENCE: So you want us to return true if we find it, and false if we 743 00:35:29,730 --> 00:35:30,480 don't find it. 744 00:35:30,480 --> 00:35:32,160 >> JASON HIRSCHHORN: How did you know? 745 00:35:32,160 --> 00:35:33,100 How did you know that? 746 00:35:33,100 --> 00:35:36,500 >> AUDIENCE: I was asking first, but I was assuming, because it says bool at 747 00:35:36,500 --> 00:35:37,490 the beginning of the function. 748 00:35:37,490 --> 00:35:37,880 >> JASON HIRSCHHORN: Right. 749 00:35:37,880 --> 00:35:41,020 It says bool, so I don't even need to tell you what I expect you to return 750 00:35:41,020 --> 00:35:41,350 because it says right there. 751 00:35:41,350 --> 00:35:42,280 But that's right. 752 00:35:42,280 --> 00:35:43,510 Return, true or false. 753 00:35:43,510 --> 00:35:47,630 >> So before you begin, I would recommend, if you are unfamiliar with 754 00:35:47,630 --> 00:35:51,300 binary search trees, quickly drawing a picture of it to get your 755 00:35:51,300 --> 00:35:51,750 understanding, right. 756 00:35:51,750 --> 00:35:54,720 That will also help you when writing your code and checking it. 757 00:35:54,720 --> 00:35:57,830 Again, you also don't have that much time on the quiz to do all the things 758 00:35:57,830 --> 00:35:59,030 that we ask you to do. 759 00:35:59,030 --> 00:36:02,350 So writing pseudo code is very helpful. 760 00:36:02,350 --> 00:36:05,310 >> And we generally give about-- 761 00:36:05,310 --> 00:36:06,820 if the pseudocode is perfectly correct, that's 762 00:36:06,820 --> 00:36:08,910 generally 50% on a question. 763 00:36:08,910 --> 00:36:11,410 So it's not a hard and fast rule, but if you just write pseudocode and it's 764 00:36:11,410 --> 00:36:13,460 correct, it's generally 50%. 765 00:36:13,460 --> 00:36:14,970 So I'd always recommend-- 766 00:36:14,970 --> 00:36:16,870 if you're pressed for time, or even if you're just trying to figure it out-- 767 00:36:16,870 --> 00:36:18,290 starting with the pseudocode. 768 00:36:18,290 --> 00:36:24,840 And finally, if you could write this all in C, that would be fantastic. 769 00:36:24,840 --> 00:36:29,010 >> So let's take three minutes to work on this program. 770 00:36:29,010 --> 00:36:33,120 And then we are going to write pseudocode for it just once, and then 771 00:36:33,120 --> 00:36:35,455 we're going to code it recursively and then iteratively. 772 00:36:35,455 --> 00:37:28,720 773 00:37:28,720 --> 00:37:30,760 >> If you have any questions, feel free raise your hand. 774 00:37:30,760 --> 00:37:34,270 Happy to walk around and answer them before we start as a group. 775 00:37:34,270 --> 00:39:22,600 776 00:39:22,600 --> 00:39:27,200 >> Let us resume, and we're going to pseudocode the recursive version of 777 00:39:27,200 --> 00:39:29,830 this, and then we will code it. 778 00:39:29,830 --> 00:39:33,380 So a recursive function needs two things. 779 00:39:33,380 --> 00:39:35,960 This might be a question that you could be asked. 780 00:39:35,960 --> 00:39:37,950 Needs two things. 781 00:39:37,950 --> 00:39:40,610 Who can raise their hand and tell me what the two things a recursive 782 00:39:40,610 --> 00:39:43,680 function needs? 783 00:39:43,680 --> 00:39:45,030 By definition it has two things. 784 00:39:45,030 --> 00:39:46,280 What are those two things? 785 00:39:46,280 --> 00:39:48,580 786 00:39:48,580 --> 00:39:49,830 New hands. 787 00:39:49,830 --> 00:39:55,050 788 00:39:55,050 --> 00:39:56,390 Yes, Alden. 789 00:39:56,390 --> 00:39:57,980 >> AUDIENCE: So I'm not exactly sure if this is the terminology, but-- 790 00:39:57,980 --> 00:39:59,715 >> JASON HIRSCHHORN: I'm glad you're raising your hand. 791 00:39:59,715 --> 00:40:03,380 >> AUDIENCE: It needs a base case, and it needs a recursive step. 792 00:40:03,380 --> 00:40:03,960 >> JASON HIRSCHHORN: Perfect. 793 00:40:03,960 --> 00:40:06,340 It needs a base case and a recursive step. 794 00:40:06,340 --> 00:40:10,430 So what's our base case here? 795 00:40:10,430 --> 00:40:12,950 >> AUDIENCE: F root equals equals null. 796 00:40:12,950 --> 00:40:15,110 Sorry, just in pseudocode, if it's null. 797 00:40:15,110 --> 00:40:16,360 If root is null. 798 00:40:16,360 --> 00:40:21,900 799 00:40:21,900 --> 00:40:23,540 >> JASON HIRSCHHORN: If root is null. 800 00:40:23,540 --> 00:40:23,850 That's excellent. 801 00:40:23,850 --> 00:40:24,610 That's our base case. 802 00:40:24,610 --> 00:40:25,910 That's what we're going to check every time. 803 00:40:25,910 --> 00:40:28,000 And base case is the first thing you do. 804 00:40:28,000 --> 00:40:29,720 If you hit the base case, you're done. 805 00:40:29,720 --> 00:40:34,140 >> Now we need our recursive call, and I'd be willing to bet we need a couple 806 00:40:34,140 --> 00:40:35,440 recursive calls here. 807 00:40:35,440 --> 00:40:39,630 Because it's a tree, and we could go multiple ways. 808 00:40:39,630 --> 00:40:43,190 So if root is null, we're good. 809 00:40:43,190 --> 00:40:44,970 >> What do you propose? 810 00:40:44,970 --> 00:40:49,640 And now I'm going to start calling out on you guys, because I know you guys 811 00:40:49,640 --> 00:40:50,540 all know this. 812 00:40:50,540 --> 00:40:52,610 But Annie, what should the next line be? 813 00:40:52,610 --> 00:40:53,570 What if we found it? 814 00:40:53,570 --> 00:40:55,526 What do we do? 815 00:40:55,526 --> 00:40:57,300 >> AUDIENCE: If we found it? 816 00:40:57,300 --> 00:40:59,160 >> JASON HIRSCHHORN: Or what should be that-- 817 00:40:59,160 --> 00:41:02,124 give me the pseudocode for the line where we found it. 818 00:41:02,124 --> 00:41:04,700 >> AUDIENCE: If i equals root i? 819 00:41:04,700 --> 00:41:06,650 >> JASON HIRSCHHORN: And then what do we do? 820 00:41:06,650 --> 00:41:07,590 >> AUDIENCE: Return true. 821 00:41:07,590 --> 00:41:08,530 >> JASON HIRSCHHORN: Great. 822 00:41:08,530 --> 00:41:16,890 So if i is i-- 823 00:41:16,890 --> 00:41:17,400 oh, they're both called i. 824 00:41:17,400 --> 00:41:18,470 That gets confusing. 825 00:41:18,470 --> 00:41:23,830 But if i is i return true. 826 00:41:23,830 --> 00:41:25,620 That's probably the next thing we should do. 827 00:41:25,620 --> 00:41:27,300 Makes sense. 828 00:41:27,300 --> 00:41:30,610 >> OK, now we haven't done our recursive call yet, though, because a recursive 829 00:41:30,610 --> 00:41:32,300 call would call this function again. 830 00:41:32,300 --> 00:41:41,460 So what should the next line of pseudocode be? 831 00:41:41,460 --> 00:41:42,730 Anna. 832 00:41:42,730 --> 00:41:43,980 >> AUDIENCE: The left side. 833 00:41:43,980 --> 00:41:47,040 834 00:41:47,040 --> 00:41:47,590 >> JASON HIRSCHHORN: Be specific, though. 835 00:41:47,590 --> 00:41:50,600 This is a binary search tree, so what does checking the left side entail? 836 00:41:50,600 --> 00:41:51,890 >> AUDIENCE: So node-- 837 00:41:51,890 --> 00:41:53,342 I'm sorry, root. 838 00:41:53,342 --> 00:41:55,306 And then arrow left. 839 00:41:55,306 --> 00:41:59,234 840 00:41:59,234 --> 00:42:00,720 Node, node, sorry. 841 00:42:00,720 --> 00:42:01,978 I'm not reading it properly. 842 00:42:01,978 --> 00:42:05,700 It's called node, right? 843 00:42:05,700 --> 00:42:09,270 >> JASON HIRSCHHORN: It will be called root in that function, but either way. 844 00:42:09,270 --> 00:42:10,925 The left side-- yeah? 845 00:42:10,925 --> 00:42:13,780 >> AUDIENCE: If it doesn't equal i, then we're going to call 846 00:42:13,780 --> 00:42:15,130 the function again? 847 00:42:15,130 --> 00:42:15,490 >> JASON HIRSCHHORN: That's right. 848 00:42:15,490 --> 00:42:17,870 If it doesn't equal i, we're going to call the function again. 849 00:42:17,870 --> 00:42:21,435 But what side of the tree are we going to call the function again? 850 00:42:21,435 --> 00:42:22,685 >> AUDIENCE: On the left side. 851 00:42:22,685 --> 00:42:25,932 852 00:42:25,932 --> 00:42:27,670 >> JASON HIRSCHHORN: We're not always going to call it the left, if it 853 00:42:27,670 --> 00:42:29,190 doesn't equal it. 854 00:42:29,190 --> 00:42:29,610 >> AUDIENCE: Oh, sorry. 855 00:42:29,610 --> 00:42:31,200 Call on the right. 856 00:42:31,200 --> 00:42:33,680 >> JASON HIRSCHHORN: We want to know specifically, though-- remember, in a 857 00:42:33,680 --> 00:42:37,700 binary search tree, everything to the left hand side is smaller. 858 00:42:37,700 --> 00:42:40,460 Everything to the right hand side is greater. 859 00:42:40,460 --> 00:42:43,990 So it's just not-- yeah, go ahead. 860 00:42:43,990 --> 00:42:46,805 >> AUDIENCE: If it's less than i, then-- 861 00:42:46,805 --> 00:42:52,130 862 00:42:52,130 --> 00:42:53,380 if it's on the left-- 863 00:42:53,380 --> 00:42:56,160 864 00:42:56,160 --> 00:42:58,606 >> JASON HIRSCHHORN: So if ri is less than-- 865 00:42:58,606 --> 00:43:01,854 866 00:43:01,854 --> 00:43:09,110 so if our number is less than i, what side do we want to go to? 867 00:43:09,110 --> 00:43:15,120 >> AUDIENCE: We want to go to the right side. 868 00:43:15,120 --> 00:43:16,250 >> JASON HIRSCHHORN: We want to go-- 869 00:43:16,250 --> 00:43:19,210 let me draw a quick tree. 870 00:43:19,210 --> 00:43:23,850 If this is 5, this will be 3. 871 00:43:23,850 --> 00:43:29,410 So if ri is less than five, what side do we want to go to? 872 00:43:29,410 --> 00:43:30,390 >> AUDIENCE: Sorry, what? 873 00:43:30,390 --> 00:43:33,190 >> JASON HIRSCHHORN: Our number is less than the number we're 874 00:43:33,190 --> 00:43:34,710 looking at right now. 875 00:43:34,710 --> 00:43:35,890 >> AUDIENCE: Oh, then we want to go to the left side. 876 00:43:35,890 --> 00:43:36,240 Yeah. 877 00:43:36,240 --> 00:43:36,920 Sorry. 878 00:43:36,920 --> 00:43:37,230 >> JASON HIRSCHHORN: Exactly. 879 00:43:37,230 --> 00:43:38,480 No worries. 880 00:43:38,480 --> 00:43:41,020 In the binary search tree, everything lower is to the left, 881 00:43:41,020 --> 00:43:42,110 greater is to the right. 882 00:43:42,110 --> 00:43:46,700 So if our number is less than the i we're checking-- 883 00:43:46,700 --> 00:43:48,790 because you see in the node, it has an i-- 884 00:43:48,790 --> 00:43:50,040 then you want to go to the left. 885 00:43:50,040 --> 00:43:55,480 886 00:43:55,480 --> 00:43:56,720 >> And this is an easy one. 887 00:43:56,720 --> 00:44:01,700 What is it the other line of pseudocode we need to write? 888 00:44:01,700 --> 00:44:02,910 Carlos? 889 00:44:02,910 --> 00:44:05,970 >> AUDIENCE: Same thing, you just switch it to a greater than sign 890 00:44:05,970 --> 00:44:07,420 and go to the right. 891 00:44:07,420 --> 00:44:08,350 >> JASON HIRSCHHORN: Can you say it one more time? 892 00:44:08,350 --> 00:44:11,640 >> AUDIENCE: If our number is greater than i, go to the right. 893 00:44:11,640 --> 00:44:24,900 894 00:44:24,900 --> 00:44:26,690 >> JASON HIRSCHHORN: Excellent job on the pseudocode. 895 00:44:26,690 --> 00:44:28,700 Let us do this in real code. 896 00:44:28,700 --> 00:44:33,280 And again, this pseudocode will probably get you, because it's 897 00:44:33,280 --> 00:44:35,480 correct, 50% on this question. 898 00:44:35,480 --> 00:44:39,720 But this pseudocode also translates one to one, essentially, into code. 899 00:44:39,720 --> 00:44:44,380 >> So let us do this in C. Who can give me the first line of code? 900 00:44:44,380 --> 00:44:48,390 Actually, first, before I do that, let me pull over-- 901 00:44:48,390 --> 00:44:49,260 >> AUDIENCE: I have a question. 902 00:44:49,260 --> 00:44:52,430 Why did you indent the line I gave you? 903 00:44:52,430 --> 00:44:54,160 >> JASON HIRSCHHORN: Because I couldn't write. 904 00:44:54,160 --> 00:44:55,240 I don't know. 905 00:44:55,240 --> 00:44:55,650 You're right. 906 00:44:55,650 --> 00:44:57,780 That line should be over there. 907 00:44:57,780 --> 00:45:11,600 908 00:45:11,600 --> 00:45:14,480 >> OK, here is our function. 909 00:45:14,480 --> 00:45:18,090 And let me pull over, also, our definition of a node. 910 00:45:18,090 --> 00:45:23,320 911 00:45:23,320 --> 00:45:27,180 What happens if we didn't write typedef? 912 00:45:27,180 --> 00:45:30,240 Does anybody know? 913 00:45:30,240 --> 00:45:32,570 >> AUDIENCE: It wouldn't compile. 914 00:45:32,570 --> 00:45:33,860 >> JASON HIRSCHHORN: It would compile, yeah. 915 00:45:33,860 --> 00:45:37,120 >> AUDIENCE: Would it just declare one instance instead of making it a new 916 00:45:37,120 --> 00:45:39,840 type you could declare multiple instances of? 917 00:45:39,840 --> 00:45:41,700 >> JASON HIRSCHHORN: So it wouldn't know-- it wouldn't 918 00:45:41,700 --> 00:45:43,120 just declare one type. 919 00:45:43,120 --> 00:45:46,150 You could still make a lot of nodes. 920 00:45:46,150 --> 00:45:48,070 >> AUDIENCE: But wouldn't we have to write struct node every time? 921 00:45:48,070 --> 00:45:48,640 >> JASON HIRSCHHORN: That's right. 922 00:45:48,640 --> 00:45:50,960 You would have to write struct node every time, instead of just node. 923 00:45:50,960 --> 00:45:55,270 But with typedef, you can just write node every single time. 924 00:45:55,270 --> 00:45:58,240 OK, who hasn't given-- yeah, Avica. 925 00:45:58,240 --> 00:46:01,520 >> AUDIENCE: If root equals equals null, return false. 926 00:46:01,520 --> 00:46:07,130 927 00:46:07,130 --> 00:46:09,490 >> JASON HIRSCHHORN: Great, and that's our base case. 928 00:46:09,490 --> 00:46:11,200 Next line of code. 929 00:46:11,200 --> 00:46:13,999 Somebody who hasn't given me a line of code yet? 930 00:46:13,999 --> 00:46:14,945 Yeah. 931 00:46:14,945 --> 00:46:23,360 >> AUDIENCE: Root arrow i is equal equal to i. 932 00:46:23,360 --> 00:46:27,260 Then return true. 933 00:46:27,260 --> 00:46:29,162 >> JASON HIRSCHHORN: Great. 934 00:46:29,162 --> 00:46:32,048 Next line? 935 00:46:32,048 --> 00:46:32,790 Yeah. 936 00:46:32,790 --> 00:46:34,010 Someone else? 937 00:46:34,010 --> 00:46:36,774 And then you can go next. 938 00:46:36,774 --> 00:46:44,820 >> AUDIENCE: Else if root arrow i is less than i return 939 00:46:44,820 --> 00:46:47,737 function called find root-- 940 00:46:47,737 --> 00:46:50,611 >> JASON HIRSCHHORN: Sorry. 941 00:46:50,611 --> 00:46:56,272 >> AUDIENCE: Return find root points to left comma i. 942 00:46:56,272 --> 00:47:01,760 943 00:47:01,760 --> 00:47:08,440 >> JASON HIRSCHHORN: So if ri is greater than the thing in the tree, we want to 944 00:47:08,440 --> 00:47:09,573 go to the left? 945 00:47:09,573 --> 00:47:11,790 >> AUDIENCE: No, I had that switched. 946 00:47:11,790 --> 00:47:13,040 >> JASON HIRSCHHORN: Which one? 947 00:47:13,040 --> 00:47:16,310 948 00:47:16,310 --> 00:47:16,950 >> AUDIENCE: No, yeah. 949 00:47:16,950 --> 00:47:19,050 I have a less than sign there. 950 00:47:19,050 --> 00:47:22,890 >> JASON HIRSCHHORN: Right, if ri is less than what's in the root-- 951 00:47:22,890 --> 00:47:25,660 our current root-- then we want to go to the left. 952 00:47:25,660 --> 00:47:26,960 And what's the last line, you? 953 00:47:26,960 --> 00:47:30,930 >> AUDIENCE: Basically the same thing, except switch the greater than or 954 00:47:30,930 --> 00:47:34,690 equal to less than and left to right. 955 00:47:34,690 --> 00:47:43,590 956 00:47:43,590 --> 00:47:43,680 >> JASON HIRSCHHORN: Excellent. 957 00:47:43,680 --> 00:47:48,430 Does anybody have any questions about this? 958 00:47:48,430 --> 00:47:52,560 So some other things that would have been correct is that 959 00:47:52,560 --> 00:47:53,810 could be the -ltiff. 960 00:47:53,810 --> 00:47:56,520 961 00:47:56,520 --> 00:47:59,520 Guess, technically, none of these really also need to be -ltiff. 962 00:47:59,520 --> 00:48:00,950 >> Also, there's probably only one case down here. 963 00:48:00,950 --> 00:48:02,380 So that's probably your last case. 964 00:48:02,380 --> 00:48:04,000 You don't even need that -ltiff. 965 00:48:04,000 --> 00:48:06,160 But probably good to write it, to be clear. 966 00:48:06,160 --> 00:48:06,660 Yeah. 967 00:48:06,660 --> 00:48:09,200 >> AUDIENCE: So you don't think the quiz-- if we make errors, for example, 968 00:48:09,200 --> 00:48:11,725 in syntax-- 969 00:48:11,725 --> 00:48:13,990 little syntax errors-- 970 00:48:13,990 --> 00:48:17,810 how does that get taken in the quiz? 971 00:48:17,810 --> 00:48:21,300 >> JASON HIRSCHHORN: Generally on the quiz, small syntax errors or small 972 00:48:21,300 --> 00:48:24,010 style errors don't lose you points. 973 00:48:24,010 --> 00:48:26,610 So if you forgot a semicolon here, it would be OK. 974 00:48:26,610 --> 00:48:30,290 If you forgot to close this parenthesis, that would be OK. 975 00:48:30,290 --> 00:48:34,880 >> Huge syntax errors that alter the functional meaning of your code 976 00:48:34,880 --> 00:48:37,600 dramatically, you might get taken off points for. 977 00:48:37,600 --> 00:48:40,330 Or generally, just grading you on whether or not your 978 00:48:40,330 --> 00:48:42,150 code functions, even-- 979 00:48:42,150 --> 00:48:44,830 not its design so much, and not its style. 980 00:48:44,830 --> 00:48:50,780 981 00:48:50,780 --> 00:48:55,480 >> Let's now code an iterative version of find. 982 00:48:55,480 --> 00:49:00,400 983 00:49:00,400 --> 00:49:03,450 So it's going to be pretty similar, but there are certainly going to be 984 00:49:03,450 --> 00:49:06,250 some key differences. 985 00:49:06,250 --> 00:49:09,160 However, our pseudocode can probably go-- 986 00:49:09,160 --> 00:49:11,610 we can still take one line of the pseudocode and figure out what the 987 00:49:11,610 --> 00:49:14,160 line is in this case. 988 00:49:14,160 --> 00:49:18,010 >> So in an iterative version, what do you think, Julia, should 989 00:49:18,010 --> 00:49:19,260 be the first line? 990 00:49:19,260 --> 00:49:23,100 991 00:49:23,100 --> 00:49:26,920 >> AUDIENCE: Again, in iterative boolean, you need to set up a for loop, right? 992 00:49:26,920 --> 00:49:27,660 >> JASON HIRSCHHORN: OK. 993 00:49:27,660 --> 00:49:38,480 >> AUDIENCE: So for like, k, for x equals 0, x is less than i. 994 00:49:38,480 --> 00:49:42,260 Or no, x is less than the size of the tree. 995 00:49:42,260 --> 00:49:42,760 >> JASON HIRSCHHORN: The tree. 996 00:49:42,760 --> 00:49:46,660 So we don't really know the size of the tree, and we don't really know for 997 00:49:46,660 --> 00:49:48,900 how many times we can go, so what's a different type of loop that might be 998 00:49:48,900 --> 00:49:50,150 better in this case? 999 00:49:50,150 --> 00:49:53,250 1000 00:49:53,250 --> 00:49:55,244 >> AUDIENCE: If else? 1001 00:49:55,244 --> 00:49:57,070 >> JASON HIRSCHHORN: If else cannot be a loop. 1002 00:49:57,070 --> 00:49:58,935 So what's a type of loop we can just go until some case is met? 1003 00:49:58,935 --> 00:50:07,250 1004 00:50:07,250 --> 00:50:11,560 What's the only other type of loop in C besides a for loop? 1005 00:50:11,560 --> 00:50:11,930 >> AUDIENCE: While. 1006 00:50:11,930 --> 00:50:13,380 >> JASON HIRSCHHORN: While, exactly. 1007 00:50:13,380 --> 00:50:16,430 In a while loop, don't need to know how-- 1008 00:50:16,430 --> 00:50:18,450 a while loop and for loop can do the exact same thing, but the nice thing 1009 00:50:18,450 --> 00:50:21,500 about a while loop is we don't need to know how big our tree is. 1010 00:50:21,500 --> 00:50:23,060 So we're going to go until what? 1011 00:50:23,060 --> 00:50:25,880 1012 00:50:25,880 --> 00:50:28,032 >> AUDIENCE: Until it equals the size of-- 1013 00:50:28,032 --> 00:50:32,320 >> JASON HIRSCHHORN: Well, it's very similar to our recursive case. 1014 00:50:32,320 --> 00:50:33,360 So-- 1015 00:50:33,360 --> 00:50:36,470 >> AUDIENCE: While root i does not equal i. 1016 00:50:36,470 --> 00:50:37,620 >> JASON HIRSCHHORN: That's really close. 1017 00:50:37,620 --> 00:50:39,430 While root i-- 1018 00:50:39,430 --> 00:50:40,610 let's try it. 1019 00:50:40,610 --> 00:50:41,180 I don't think [INAUDIBLE] 1020 00:50:41,180 --> 00:50:43,026 where root i does not equal i. 1021 00:50:43,026 --> 00:50:47,380 1022 00:50:47,380 --> 00:50:49,460 We might need to change it in a little bit, but that sounds like it's pretty 1023 00:50:49,460 --> 00:50:50,160 good, for now. 1024 00:50:50,160 --> 00:50:51,710 So we'll do that. 1025 00:50:51,710 --> 00:50:55,660 >> Also, remember, we can't assume per the question. 1026 00:50:55,660 --> 00:50:57,880 You do not assume that the root will be non-null. 1027 00:50:57,880 --> 00:51:01,914 So what do you think the very first thing we should do is? 1028 00:51:01,914 --> 00:51:02,770 >> AUDIENCE: Just do the same thing as before. 1029 00:51:02,770 --> 00:51:05,260 If the root equals equals null, return false. 1030 00:51:05,260 --> 00:51:11,030 1031 00:51:11,030 --> 00:51:12,130 >> JASON HIRSCHHORN: Great. 1032 00:51:12,130 --> 00:51:13,820 So it could be null. 1033 00:51:13,820 --> 00:51:15,810 So we want to get rid of it right away. 1034 00:51:15,810 --> 00:51:19,560 And then we're going check if root i does not equal i. 1035 00:51:19,560 --> 00:51:24,480 So, say we're searching in this tree for 3, root i does not equal i, now 1036 00:51:24,480 --> 00:51:25,950 we're in our while loop. 1037 00:51:25,950 --> 00:51:27,500 What do we want to do? 1038 00:51:27,500 --> 00:51:32,320 1039 00:51:32,320 --> 00:51:35,430 And again, it's going to be pretty similar to our recursive version. 1040 00:51:35,430 --> 00:51:36,230 Yeah. 1041 00:51:36,230 --> 00:51:40,470 >> AUDIENCE: So you'd want to iterate, or keep going down the tree as long as 1042 00:51:40,470 --> 00:51:42,400 the root is not equal to null. 1043 00:51:42,400 --> 00:51:45,120 1044 00:51:45,120 --> 00:51:46,640 >> JASON HIRSCHHORN: As long as the root is not equal to null? 1045 00:51:46,640 --> 00:51:50,200 >> AUDIENCE: The root dash i is not equal to null. 1046 00:51:50,200 --> 00:51:51,220 Just the root, yeah. 1047 00:51:51,220 --> 00:51:52,920 As a long as the root is not equal to null. 1048 00:51:52,920 --> 00:51:54,240 >> JASON HIRSCHHORN: So you want to change this into root 1049 00:51:54,240 --> 00:51:56,590 does not equal null? 1050 00:51:56,590 --> 00:51:59,020 >> AUDIENCE: Yeah. 1051 00:51:59,020 --> 00:52:00,800 >> AUDIENCE: We could combine these, right? 1052 00:52:00,800 --> 00:52:02,990 We don't need the if, initially. 1053 00:52:02,990 --> 00:52:05,180 >> JASON HIRSCHHORN: OK, so if we don't-- 1054 00:52:05,180 --> 00:52:08,140 if we combine them, so we're going to do while root does not equal null, and 1055 00:52:08,140 --> 00:52:10,800 if the root happens to be null at the beginning, what do we do down here? 1056 00:52:10,800 --> 00:52:11,450 >> AUDIENCE: Return false. 1057 00:52:11,450 --> 00:52:12,730 >> JASON HIRSCHHORN: Great. 1058 00:52:12,730 --> 00:52:14,110 So both ways probably would have worked. 1059 00:52:14,110 --> 00:52:15,645 This is a different way, and this combines it. 1060 00:52:15,645 --> 00:52:18,950 But again, if you did either way, we're not going to take off design 1061 00:52:18,950 --> 00:52:19,800 points on the quiz. 1062 00:52:19,800 --> 00:52:21,020 But this looks good. 1063 00:52:21,020 --> 00:52:23,940 >> So while root does not equal null, what is the first 1064 00:52:23,940 --> 00:52:25,400 thing we want to check? 1065 00:52:25,400 --> 00:52:26,330 Somebody else? 1066 00:52:26,330 --> 00:52:29,720 Null, what's the first thing? 1067 00:52:29,720 --> 00:52:32,850 >> AUDIENCE: If ri is less than-- 1068 00:52:32,850 --> 00:52:36,140 oh, I guess, if we already found it in the root. 1069 00:52:36,140 --> 00:52:40,830 So if root arrow i is equal to i-- 1070 00:52:40,830 --> 00:52:40,990 >> JASON HIRSCHHORN: Sorry? 1071 00:52:40,990 --> 00:52:45,840 >> AUDIENCE: If root arrow i equals equals i-- 1072 00:52:45,840 --> 00:52:47,090 >> JASON HIRSCHHORN: What do we do? 1073 00:52:47,090 --> 00:52:50,300 1074 00:52:50,300 --> 00:52:51,550 >> AUDIENCE: Return true. 1075 00:52:51,550 --> 00:52:58,850 1076 00:52:58,850 --> 00:52:59,280 >> JASON HIRSCHHORN: Great. 1077 00:52:59,280 --> 00:53:00,530 And what's next? 1078 00:53:00,530 --> 00:53:04,510 1079 00:53:04,510 --> 00:53:06,843 Jeff, what's the next line of code? 1080 00:53:06,843 --> 00:53:16,190 >> AUDIENCE: If i is less than root arrow i, then root equals root arrow left. 1081 00:53:16,190 --> 00:53:21,550 >> JASON HIRSCHHORN: Root equals root arrow left. 1082 00:53:21,550 --> 00:53:24,530 So that's probably the biggest difference here in this iterative 1083 00:53:24,530 --> 00:53:26,600 version as opposed to the recursive version. 1084 00:53:26,600 --> 00:53:28,970 The recursive version, we call the function again. 1085 00:53:28,970 --> 00:53:32,640 We'll be updating root when we call the new function. 1086 00:53:32,640 --> 00:53:34,170 Here we're not calling a new function. 1087 00:53:34,170 --> 00:53:37,610 We're simply just updating root in this function. 1088 00:53:37,610 --> 00:53:38,880 That's excellent. 1089 00:53:38,880 --> 00:53:40,730 And what is the last line of code? 1090 00:53:40,730 --> 00:53:43,950 1091 00:53:43,950 --> 00:53:44,880 Yeah, Mario? 1092 00:53:44,880 --> 00:53:48,290 >> AUDIENCE: Else root equals root arrow right. 1093 00:53:48,290 --> 00:53:49,492 >> JASON HIRSCHHORN: Sorry? 1094 00:53:49,492 --> 00:53:52,340 >> AUDIENCE: Root equals root arrow right. 1095 00:53:52,340 --> 00:53:55,590 1096 00:53:55,590 --> 00:53:57,140 >> JASON HIRSCHHORN: Could you also write something like this? 1097 00:53:57,140 --> 00:54:02,786 1098 00:54:02,786 --> 00:54:03,890 >> AUDIENCE: I have no idea. 1099 00:54:03,890 --> 00:54:05,140 >> JASON HIRSCHHORN: You can't. 1100 00:54:05,140 --> 00:54:07,302 1101 00:54:07,302 --> 00:54:08,270 You can't do plus equals. 1102 00:54:08,270 --> 00:54:10,780 OK, so this looks good. 1103 00:54:10,780 --> 00:54:13,620 Why don't we just do that to clean it up. 1104 00:54:13,620 --> 00:54:15,220 This looks great, and this would work. 1105 00:54:15,220 --> 00:54:16,920 And we would break out. 1106 00:54:16,920 --> 00:54:21,460 >> If root left was null or root right was null, we would come up here. 1107 00:54:21,460 --> 00:54:22,470 Root would be equal to null. 1108 00:54:22,470 --> 00:54:24,270 We'd break out of our loop, and we'd return false. 1109 00:54:24,270 --> 00:54:26,280 So when we break out of the loop, we return false. 1110 00:54:26,280 --> 00:54:29,520 1111 00:54:29,520 --> 00:54:32,793 >> And again, the a while loop was perfect here because we don't know how 1112 00:54:32,793 --> 00:54:33,850 big our tree is. 1113 00:54:33,850 --> 00:54:36,460 We tried to write the for loop, but we realized you've got to figure out how 1114 00:54:36,460 --> 00:54:37,410 big it is ahead of time. 1115 00:54:37,410 --> 00:54:38,720 Yeah. 1116 00:54:38,720 --> 00:54:41,790 >> AUDIENCE: If this weren't a binary search tree, it would be real math-y 1117 00:54:41,790 --> 00:54:44,220 to write it iteratively, right? 1118 00:54:44,220 --> 00:54:47,170 Like, if it was a tree, but not necessarily-- 1119 00:54:47,170 --> 00:54:49,730 so it wasn't all smaller on the left, and all bigger on the right. 1120 00:54:49,730 --> 00:54:52,540 It would be really difficult to iterate over it, right? 1121 00:54:52,540 --> 00:54:55,720 We'd have to save what was earlier on in the tree and go back, 1122 00:54:55,720 --> 00:54:56,970 and stuff like that. 1123 00:54:56,970 --> 00:54:59,690 1124 00:54:59,690 --> 00:55:02,010 >> JASON HIRSCHHORN: If it wasn't a binary search tree, if it was just a 1125 00:55:02,010 --> 00:55:04,740 tree and things weren't sorted like this-- 1126 00:55:04,740 --> 00:55:07,440 and we realized earlier when Anna was helping us that making it 1127 00:55:07,440 --> 00:55:08,800 sorted helps us a lot-- 1128 00:55:08,800 --> 00:55:12,610 we would need to, yes, always save where we were previously. 1129 00:55:12,610 --> 00:55:14,430 But there could be a lot of where we were previouslys. 1130 00:55:14,430 --> 00:55:17,730 There could be a lot of parent nodes. 1131 00:55:17,730 --> 00:55:22,530 >> Probably the best way to do that would be to keep pushing things onto some 1132 00:55:22,530 --> 00:55:24,170 type of stack or queue. 1133 00:55:24,170 --> 00:55:26,030 You would never need to code this because it's a hard problem. 1134 00:55:26,030 --> 00:55:30,820 But you push some things onto a stack or queue and then pop them off, and 1135 00:55:30,820 --> 00:55:31,890 then evaluate them. 1136 00:55:31,890 --> 00:55:34,200 >> And then have some other thing where you're actually putting the nodes, and 1137 00:55:34,200 --> 00:55:36,090 then create that, and then search through that. 1138 00:55:36,090 --> 00:55:38,700 That might be the best way to do it. 1139 00:55:38,700 --> 00:55:42,410 OK, any questions about this problem? 1140 00:55:42,410 --> 00:55:44,670 >> AUDIENCE: This is on a related note. 1141 00:55:44,670 --> 00:55:50,460 Will we have to compare run times for hash tables, binary 1142 00:55:50,460 --> 00:55:52,160 search trees, et cetera? 1143 00:55:52,160 --> 00:55:54,310 >> JASON HIRSCHHORN: Probably. 1144 00:55:54,310 --> 00:55:56,150 So let's do that really quickly. 1145 00:55:56,150 --> 00:55:58,490 Run time for hash table-- 1146 00:55:58,490 --> 00:55:59,090 what are the others? 1147 00:55:59,090 --> 00:56:00,050 Binary tree? 1148 00:56:00,050 --> 00:56:02,920 >> AUDIENCE: Link lists. 1149 00:56:02,920 --> 00:56:04,780 >> JASON HIRSCHHORN: OK, let's do insert. 1150 00:56:04,780 --> 00:56:09,980 What is the big O of insert on a hash table? 1151 00:56:09,980 --> 00:56:13,080 1152 00:56:13,080 --> 00:56:15,285 What are the assumptions you're making? 1153 00:56:15,285 --> 00:56:17,760 >> AUDIENCE: You're inserting at the beginning of the link list. 1154 00:56:17,760 --> 00:56:19,860 >> JASON HIRSCHHORN: Probably the first assumption is there are no collisions. 1155 00:56:19,860 --> 00:56:22,340 If there are no collisions, then the insertion time is one. 1156 00:56:22,340 --> 00:56:26,560 If there are collisions, and you're doing separate chaining and inserting 1157 00:56:26,560 --> 00:56:31,880 at the beginning of the link list, then insertion is also constant. 1158 00:56:31,880 --> 00:56:34,700 >> If you're doing a hash table but you have a different method of dealing 1159 00:56:34,700 --> 00:56:36,040 with collisions, what's a different method? 1160 00:56:36,040 --> 00:56:41,580 1161 00:56:41,580 --> 00:56:42,960 What's is a different method of dealing with 1162 00:56:42,960 --> 00:56:44,205 collision in a hash table? 1163 00:56:44,205 --> 00:56:44,915 >> AUDIENCE: Linear programming. 1164 00:56:44,915 --> 00:56:45,540 >> JASON HIRSCHHORN: Linear programming. 1165 00:56:45,540 --> 00:56:47,770 So we're going to keep looking for the next open spot. 1166 00:56:47,770 --> 00:56:50,390 That is not constant insertion time. 1167 00:56:50,390 --> 00:56:52,266 You could have to go through the entire table, so that 1168 00:56:52,266 --> 00:56:53,936 could be big O of n. 1169 00:56:53,936 --> 00:56:54,740 Yeah. 1170 00:56:54,740 --> 00:56:57,690 >> AUDIENCE: Otherwise just chaining? 1171 00:56:57,690 --> 00:57:00,160 >> JASON HIRSCHHORN: We did separate chaining. 1172 00:57:00,160 --> 00:57:00,720 That was the first one. 1173 00:57:00,720 --> 00:57:01,560 That's what the link list. 1174 00:57:01,560 --> 00:57:03,720 The fancy name is separate chaining. 1175 00:57:03,720 --> 00:57:06,880 It could be any type of list structure we happen to do in link list. 1176 00:57:06,880 --> 00:57:10,490 >> So again, insertion on a hash table could be constant time. 1177 00:57:10,490 --> 00:57:13,160 What about insertion on a stacker queue? 1178 00:57:13,160 --> 00:57:19,260 1179 00:57:19,260 --> 00:57:20,640 >> AUDIENCE: Isn't that constant? 1180 00:57:20,640 --> 00:57:21,530 >> JASON HIRSCHHORN: It's constant time. 1181 00:57:21,530 --> 00:57:23,420 You're just pushing it on. 1182 00:57:23,420 --> 00:57:24,120 OK. 1183 00:57:24,120 --> 00:57:25,380 Insertion, what were the other ones? 1184 00:57:25,380 --> 00:57:27,100 On a try? 1185 00:57:27,100 --> 00:57:30,252 What is big O of insertion on a try? 1186 00:57:30,252 --> 00:57:32,808 >> AUDIENCE: Length is constant. 1187 00:57:32,808 --> 00:57:34,560 Length of the longest-- 1188 00:57:34,560 --> 00:57:36,998 the length of the word you're inserting. 1189 00:57:36,998 --> 00:57:38,210 >> JASON HIRSCHHORN: Sorry? 1190 00:57:38,210 --> 00:57:39,120 Wait, so what did I hear? 1191 00:57:39,120 --> 00:57:40,260 You said-- what did you say? 1192 00:57:40,260 --> 00:57:41,650 What was your answer, Marcus? 1193 00:57:41,650 --> 00:57:43,640 >> AUDIENCE: The length of the word you're inserting in characters, 1194 00:57:43,640 --> 00:57:45,480 assuming it's a character try. 1195 00:57:45,480 --> 00:57:46,840 >> JASON HIRSCHHORN: OK, so the length of the word. 1196 00:57:46,840 --> 00:57:49,500 We'll make an assumption that it's a string of characters. 1197 00:57:49,500 --> 00:57:51,930 You said something different, though. 1198 00:57:51,930 --> 00:57:55,490 You said length of longest word. 1199 00:57:55,490 --> 00:57:57,600 >> AUDIENCE: That's just constant, right? 1200 00:57:57,600 --> 00:57:58,440 >> JASON HIRSCHHORN: Why would it be constant? 1201 00:57:58,440 --> 00:58:00,970 >> AUDIENCE: Like, if you use big O notation, then it doesn't vary based 1202 00:58:00,970 --> 00:58:04,680 on the number of things that are already in the try. 1203 00:58:04,680 --> 00:58:07,344 >> JASON HIRSCHHORN: So we would say it's constant time. 1204 00:58:07,344 --> 00:58:11,840 It is constant insertion, and that's because this idea-- 1205 00:58:11,840 --> 00:58:14,820 say we have a word that's 45, or a word that's 60, that 1206 00:58:14,820 --> 00:58:16,800 has a constant number. 1207 00:58:16,800 --> 00:58:21,050 And it would just be inserted in constant time. 1208 00:58:21,050 --> 00:58:26,060 >> In practice though, it would not be, obviously, happen in one millisecond, 1209 00:58:26,060 --> 00:58:26,590 for example. 1210 00:58:26,590 --> 00:58:28,880 But we would say big O is constant for a try. 1211 00:58:28,880 --> 00:58:31,330 And that's one of its biggest advantages. 1212 00:58:31,330 --> 00:58:33,330 >> What about insertion into a link list? 1213 00:58:33,330 --> 00:58:37,220 Just a generic, sorted link list? 1214 00:58:37,220 --> 00:58:37,700 Yeah. 1215 00:58:37,700 --> 00:58:38,530 >> AUDIENCE: I had a question. 1216 00:58:38,530 --> 00:58:42,670 On the test, would they ever ask us the insertion time that's four steps, 1217 00:58:42,670 --> 00:58:43,270 or something? 1218 00:58:43,270 --> 00:58:44,300 Or is it just-- 1219 00:58:44,300 --> 00:58:47,670 when you say insertion time is one, that just means constant time? 1220 00:58:47,670 --> 00:58:49,770 >> JASON HIRSCHHORN: Yeah, they would always ask, is it big O of n? 1221 00:58:49,770 --> 00:58:51,440 Big O of log n? 1222 00:58:51,440 --> 00:58:53,960 N squared constant. 1223 00:58:53,960 --> 00:58:56,520 Those are really the only ones you need to know. 1224 00:58:56,520 --> 00:58:58,420 What about insertion onto sorted link list? 1225 00:58:58,420 --> 00:58:59,440 >> AUDIENCE: I had a question-- 1226 00:58:59,440 --> 00:58:59,980 a question-- 1227 00:58:59,980 --> 00:59:01,060 >> JASON HIRSCHHORN: What is the answer to that question, though? 1228 00:59:01,060 --> 00:59:02,120 >> AUDIENCE: Wait, what did you ask? 1229 00:59:02,120 --> 00:59:06,750 >> JASON HIRSCHHORN: What is big O of insertion into a sorted link list? 1230 00:59:06,750 --> 00:59:07,070 >> AUDIENCE: One? 1231 00:59:07,070 --> 00:59:09,400 No wait, No wait, n. 1232 00:59:09,400 --> 00:59:11,420 >> JASON HIRSCHHORN: N. Besides the link list. 1233 00:59:11,420 --> 00:59:12,706 And what was your question? 1234 00:59:12,706 --> 00:59:16,440 >> AUDIENCE: So would you write o of k or o of 1 for the-- 1235 00:59:16,440 --> 00:59:18,150 >> JASON HIRSCHHORN: Oh. 1236 00:59:18,150 --> 00:59:21,830 I would write o of 1, probably. 1237 00:59:21,830 --> 00:59:24,160 There was one other data structure that would have been good. 1238 00:59:24,160 --> 00:59:25,730 Tree, binary search tree. 1239 00:59:25,730 --> 00:59:27,510 What's insertion on a binary search tree? 1240 00:59:27,510 --> 00:59:31,190 1241 00:59:31,190 --> 00:59:33,900 >> AUDIENCE: Login. 1242 00:59:33,900 --> 00:59:39,260 >> JASON HIRSCHHORN: So, what is the worst case in a binary search tree? 1243 00:59:39,260 --> 00:59:45,350 So if we happen to start at 5, and every number is greater than 5, then 1244 00:59:45,350 --> 00:59:48,760 we've got 5, 7, 9, 11, et cetera. 1245 00:59:48,760 --> 00:59:52,255 In this case, it's basically just a link list, and we need to insert all 1246 00:59:52,255 --> 00:59:52,680 the way at the end. 1247 00:59:52,680 --> 00:59:54,350 So it's big O of n. 1248 00:59:54,350 --> 00:59:57,720 >> That could be our worst case on a binary search tree. 1249 00:59:57,720 --> 01:00:00,890 Obviously, you would never construct a binary search tree with 5 in the 1250 01:00:00,890 --> 01:00:04,270 middle, knowing 5 would be the lowest number. 1251 01:00:04,270 --> 01:00:08,030 But it could be, if you're starting from scratch. 1252 01:00:08,030 --> 01:00:10,980 Any questions on this before I move on to another question? 1253 01:00:10,980 --> 01:00:11,560 That was a good question. 1254 01:00:11,560 --> 01:00:15,100 I would know big O of-- 1255 01:00:15,100 --> 01:00:18,620 >> AUDIENCE: What about searching for those four? 1256 01:00:18,620 --> 01:00:20,400 >> JASON HIRSCHHORN: Definitely we did searching and sorting. 1257 01:00:20,400 --> 01:00:22,160 We did all those algorithms, right. 1258 01:00:22,160 --> 01:00:23,390 Wait, was that for Quiz 1? 1259 01:00:23,390 --> 01:00:23,980 Was that covered-- 1260 01:00:23,980 --> 01:00:25,860 did you already have that question on Quiz 1? 1261 01:00:25,860 --> 01:00:29,650 The big O runtime of binary search, insertion sort, bubble sort? 1262 01:00:29,650 --> 01:00:30,160 >> AUDIENCE:Yeah. 1263 01:00:30,160 --> 01:00:32,790 >> JASON HIRSCHHORN: If you had that question on Quiz 0, odds are you won't 1264 01:00:32,790 --> 01:00:35,180 get the same exact question on Quiz 1. 1265 01:00:35,180 --> 01:00:36,300 Might be still good to know those. 1266 01:00:36,300 --> 01:00:38,520 You should hopefully know gh already. 1267 01:00:38,520 --> 01:00:40,740 >> But other logarithmic runtimes are probably good to know. 1268 01:00:40,740 --> 01:00:42,890 Things that weren't covered on Quiz 0. 1269 01:00:42,890 --> 01:00:47,300 Like all these operators on these abstract data types. 1270 01:00:47,300 --> 01:00:50,760 >> OK, let's move on. 1271 01:00:50,760 --> 01:00:52,190 This one should be pretty quick. 1272 01:00:52,190 --> 01:00:56,170 And this is a new language we haven't actually coded in before. 1273 01:00:56,170 --> 01:00:59,300 This is a question asking to code in PHP. 1274 01:00:59,300 --> 01:01:01,950 So consider the PHP array below. 1275 01:01:01,950 --> 01:01:06,150 Write PHP and/or HTML codes such that it outputs a two-column table with TFs 1276 01:01:06,150 --> 01:01:08,810 names and houses. 1277 01:01:08,810 --> 01:01:11,600 >> You've never done this before, this specific problem. 1278 01:01:11,600 --> 01:01:16,270 But this should be very familiar to what you did in problem set 7. 1279 01:01:16,270 --> 01:01:21,250 So I would be willing to bet you will be asked to code something in PHP that 1280 01:01:21,250 --> 01:01:23,880 is very similar to what you did in problem set 7. 1281 01:01:23,880 --> 01:01:26,300 >> Firstly, array is not that specific. 1282 01:01:26,300 --> 01:01:28,140 What type of array is this? 1283 01:01:28,140 --> 01:01:29,080 >> AUDIENCE: Associative. 1284 01:01:29,080 --> 01:01:31,250 >> JASON HIRSCHHORN: It's an associative array. 1285 01:01:31,250 --> 01:01:33,750 And what's the difference between an associative array and an object? 1286 01:01:33,750 --> 01:01:41,780 1287 01:01:41,780 --> 01:01:44,857 >> AUDIENCE: An object array has an index of integers, and an associative array 1288 01:01:44,857 --> 01:01:47,814 is an index of a string, or something like that. 1289 01:01:47,814 --> 01:01:50,570 1290 01:01:50,570 --> 01:01:54,880 >> JASON HIRSCHHORN: So an array of objects would have indices of 1291 01:01:54,880 --> 01:01:57,090 integers, but an object has fields. 1292 01:01:57,090 --> 01:02:01,590 It has those fields names like name, house, student. 1293 01:02:01,590 --> 01:02:03,720 Do you have an idea? 1294 01:02:03,720 --> 01:02:06,630 >> AUDIENCE: Well, associative array is in PHP, right? 1295 01:02:06,630 --> 01:02:07,880 And object is in JavaScript? 1296 01:02:07,880 --> 01:02:12,330 1297 01:02:12,330 --> 01:02:14,820 >> JASON HIRSCHHORN: Honestly, there's no real difference between the two. 1298 01:02:14,820 --> 01:02:19,540 Both have strings as the keys, and can have basically anything as the value. 1299 01:02:19,540 --> 01:02:21,250 Different languages call one thing associative array, 1300 01:02:21,250 --> 01:02:22,750 one thing an object. 1301 01:02:22,750 --> 01:02:25,960 So honestly, there is no real difference, but there's certainly some 1302 01:02:25,960 --> 01:02:27,730 syntactical differences between the two. 1303 01:02:27,730 --> 01:02:28,200 Yeah. 1304 01:02:28,200 --> 01:02:33,580 >> AUDIENCE: So is object also coded under the hood as a hash table, then? 1305 01:02:33,580 --> 01:02:35,796 >> JASON HIRSCHHORN: What do you mean, coded under the hood? 1306 01:02:35,796 --> 01:02:38,017 >> AUDIENCE: We were told that associative array was technically a 1307 01:02:38,017 --> 01:02:39,960 hash table. 1308 01:02:39,960 --> 01:02:44,510 So is object also technically a hash table? 1309 01:02:44,510 --> 01:02:45,350 >> JASON HIRSCHHORN: I'm not going to answer that question. 1310 01:02:45,350 --> 01:02:46,600 I'll get back to you on that. 1311 01:02:46,600 --> 01:02:48,980 But I wouldn't think of either of those like that. 1312 01:02:48,980 --> 01:02:53,790 But, in any way, associative array and object, generally, people use those 1313 01:02:53,790 --> 01:02:54,910 terms interchangeably. 1314 01:02:54,910 --> 01:02:57,630 In this case, the cool part is you can use keys. 1315 01:02:57,630 --> 01:03:00,580 Strings as keys, rather than just simple numbers. 1316 01:03:00,580 --> 01:03:02,070 >> So I've been talking about this for awhile. 1317 01:03:02,070 --> 01:03:04,090 Hopefully, some people have gotten started on this. 1318 01:03:04,090 --> 01:03:08,050 We're going to write some PHP and HTML code, such that we get a two-column 1319 01:03:08,050 --> 01:03:11,830 table with TFs names and houses. 1320 01:03:11,830 --> 01:03:15,380 >> OK, I also would like a header row on this table. 1321 01:03:15,380 --> 01:03:18,410 So I'm going to get straight into this. 1322 01:03:18,410 --> 01:03:20,770 We're going to file, new, and we're going to-- 1323 01:03:20,770 --> 01:03:27,780 1324 01:03:27,780 --> 01:03:28,320 >> OK. 1325 01:03:28,320 --> 01:03:29,970 How do I start a table? 1326 01:03:29,970 --> 01:03:32,090 What's the tag, Michael, to start a table? 1327 01:03:32,090 --> 01:03:32,890 >> AUDIENCE: Table. 1328 01:03:32,890 --> 01:03:34,020 >> JASON HIRSCHHORN: Table. 1329 01:03:34,020 --> 01:03:37,870 And if I open a tag, what else do I need? 1330 01:03:37,870 --> 01:03:39,810 >> AUDIENCE: A head? 1331 01:03:39,810 --> 01:03:41,040 Or, I guess, class. 1332 01:03:41,040 --> 01:03:41,730 >> JASON HIRSCHHORN: So, sorry. 1333 01:03:41,730 --> 01:03:45,430 Assume that we've already written doctab, HTML, all that stuff. 1334 01:03:45,430 --> 01:03:50,230 But if I open this table tag, what else do I need to write? 1335 01:03:50,230 --> 01:03:53,450 for validate HTML? 1336 01:03:53,450 --> 01:03:55,000 >> AUDIENCE: Close it. 1337 01:03:55,000 --> 01:03:56,050 >> JASON HIRSCHHORN: Close the tag. 1338 01:03:56,050 --> 01:03:57,575 How do I write a close-table tag? 1339 01:03:57,575 --> 01:03:59,580 >> AUDIENCE: Dot slash table. 1340 01:03:59,580 --> 01:04:00,960 >> JASON HIRSCHHORN: Slash table, great. 1341 01:04:00,960 --> 01:04:02,730 Probably makes sense to write both of those together because 1342 01:04:02,730 --> 01:04:03,870 you've got to do it. 1343 01:04:03,870 --> 01:04:08,575 OK, if I want a header row, how do I write a header row with titles? 1344 01:04:08,575 --> 01:04:11,650 1345 01:04:11,650 --> 01:04:19,290 >> AUDIENCE: Is it less than 10 hr close-- 1346 01:04:19,290 --> 01:04:21,550 TR, yeah. 1347 01:04:21,550 --> 01:04:22,100 >> JASON HIRSCHHORN: TR? 1348 01:04:22,100 --> 01:04:25,080 >> AUDIENCE: Then same thing, the slash, yeah. 1349 01:04:25,080 --> 01:04:26,610 >> JASON HIRSCHHORN: OK, and give me two columns. 1350 01:04:26,610 --> 01:04:30,100 1351 01:04:30,100 --> 01:04:33,210 >> AUDIENCE: T D? 1352 01:04:33,210 --> 01:04:34,460 >> JASON HIRSCHHORN: OK. 1353 01:04:34,460 --> 01:04:37,730 1354 01:04:37,730 --> 01:04:39,520 I want two columns. 1355 01:04:39,520 --> 01:04:40,960 Does this give me two columns? 1356 01:04:40,960 --> 01:04:43,880 How many columns is this? 1357 01:04:43,880 --> 01:04:45,920 One. 1358 01:04:45,920 --> 01:04:47,170 So let's copy and paste this. 1359 01:04:47,170 --> 01:04:59,750 1360 01:04:59,750 --> 01:05:03,390 >> So actually, on the quiz, all this code that we've written so far was 1361 01:05:03,390 --> 01:05:04,710 actually given to you. 1362 01:05:04,710 --> 01:05:06,200 But you should probably still know how to write it. 1363 01:05:06,200 --> 01:05:06,470 Yeah. 1364 01:05:06,470 --> 01:05:10,636 >> AUDIENCE: Your house is between the two. 1365 01:05:10,636 --> 01:05:11,130 >> JASON HIRSCHHORN: Boom. 1366 01:05:11,130 --> 01:05:12,720 It should go right there, right? 1367 01:05:12,720 --> 01:05:14,600 Good call. 1368 01:05:14,600 --> 01:05:17,760 So again, all this code is actually given to you on the actual quiz. 1369 01:05:17,760 --> 01:05:19,570 But it's fun to write it, and you should know how to write it. 1370 01:05:19,570 --> 01:05:23,640 So this is where you need to start your code. 1371 01:05:23,640 --> 01:05:25,150 What do we need to write right here? 1372 01:05:25,150 --> 01:05:28,640 1373 01:05:28,640 --> 01:05:30,565 >> Sorry, I need to change the name of this file. 1374 01:05:30,565 --> 01:05:41,180 1375 01:05:41,180 --> 01:05:44,270 So we saved it in a .HTML file, not in a .PHP file. 1376 01:05:44,270 --> 01:05:47,030 These things would mean nothing in a .PHP file. 1377 01:05:47,030 --> 01:05:48,500 So we're in a .HTML file. 1378 01:05:48,500 --> 01:05:50,090 What is the first thing I need to write? 1379 01:05:50,090 --> 01:05:52,990 I want to put some PHP code in an HTML. 1380 01:05:52,990 --> 01:05:57,300 >> AUDIENCE: PHP, like another carrot and question mark PHP, right? 1381 01:05:57,300 --> 01:05:58,310 >> JASON HIRSCHHORN: Great. 1382 01:05:58,310 --> 01:05:59,360 And how do I end that? 1383 01:05:59,360 --> 01:06:02,510 >> AUDIENCE: With a question mark. 1384 01:06:02,510 --> 01:06:03,120 >> JASON HIRSCHHORN: That's great. 1385 01:06:03,120 --> 01:06:07,090 That's the first thing I need if I want to put some PHP code in here. 1386 01:06:07,090 --> 01:06:11,210 >> AUDIENCE: I thought a .PHP file could take HTML. 1387 01:06:11,210 --> 01:06:12,290 >> JASON HIRSCHHORN: Yeah. 1388 01:06:12,290 --> 01:06:15,330 A .PHP file can take some HTML and be displayed. 1389 01:06:15,330 --> 01:06:16,450 That was my bad. 1390 01:06:16,450 --> 01:06:18,300 I was just trying to mimic what it was on the quiz. 1391 01:06:18,300 --> 01:06:21,910 1392 01:06:21,910 --> 01:06:24,720 >> OK, sorry to confuse you. 1393 01:06:24,720 --> 01:06:25,550 Yes, practice.HTML. 1394 01:06:25,550 --> 01:06:27,340 Now we're going to put some PHP code in. 1395 01:06:27,340 --> 01:06:30,530 What is the first line of PHP code I should write? 1396 01:06:30,530 --> 01:06:33,360 I'm going to go through this array and make it into a table. 1397 01:06:33,360 --> 01:06:34,600 Yeah. 1398 01:06:34,600 --> 01:06:37,160 >> AUDIENCE: You can either use a for H loop or a for loop. 1399 01:06:37,160 --> 01:06:38,415 >> JASON HIRSCHHORN: OK, what do you want to use? 1400 01:06:38,415 --> 01:06:40,720 >> AUDIENCE: I would use a for loop. 1401 01:06:40,720 --> 01:06:48,700 For, and then you do dollar sign i equals 0 semicolon dollar 1402 01:06:48,700 --> 01:06:51,580 sign i less than 2. 1403 01:06:51,580 --> 01:06:55,455 And then semicolon i dollar sign i plus plus. 1404 01:06:55,455 --> 01:07:01,890 1405 01:07:01,890 --> 01:07:03,880 >> JASON HIRSCHHORN: How do you know to use a 2? 1406 01:07:03,880 --> 01:07:10,444 >> AUDIENCE: Because there were two associative arrays within the bigger 1407 01:07:10,444 --> 01:07:11,960 associative array. 1408 01:07:11,960 --> 01:07:13,610 >> JASON HIRSCHHORN: So the big thing's not an associate array. 1409 01:07:13,610 --> 01:07:15,500 The big thing's just a normal array. 1410 01:07:15,500 --> 01:07:17,380 But you're right, there are two associative arrays 1411 01:07:17,380 --> 01:07:18,910 inside our larger array. 1412 01:07:18,910 --> 01:07:20,310 That's why you use two. 1413 01:07:20,310 --> 01:07:24,270 I feel uncomfortable assuming that they're 2, so what's a way to write 1414 01:07:24,270 --> 01:07:26,810 this without assuming that they're 2? 1415 01:07:26,810 --> 01:07:27,507 >> AUDIENCE: [INAUDIBLE]? 1416 01:07:27,507 --> 01:07:29,165 >> JASON HIRSCHHORN: OK, how do you write that? 1417 01:07:29,165 --> 01:07:35,262 >> AUDIENCE: Foreach dollar sign tfs or like dollar sign tf. 1418 01:07:35,262 --> 01:07:38,360 1419 01:07:38,360 --> 01:07:41,960 >> JASON HIRSCHHORN: OK, so for each tfs as tfs, I want to, now 1420 01:07:41,960 --> 01:07:43,650 again, have my table. 1421 01:07:43,650 --> 01:07:45,250 So who can give me the next line of code? 1422 01:07:45,250 --> 01:07:52,870 1423 01:07:52,870 --> 01:07:59,810 >> AUDIENCE: Print, and then in quotations, bracket tr end 1424 01:07:59,810 --> 01:08:02,670 bracket, end quote. 1425 01:08:02,670 --> 01:08:05,300 End parentheses, semicolon. 1426 01:08:05,300 --> 01:08:07,135 >> JASON HIRSCHHORN: OK, and what's that going to do? 1427 01:08:07,135 --> 01:08:08,610 >> AUDIENCE: It's going to say, new row. 1428 01:08:08,610 --> 01:08:11,070 It's going to put the tag for a new row. 1429 01:08:11,070 --> 01:08:13,000 >> JASON HIRSCHHORN: Right, this PHP, like we talked about earlier-- this 1430 01:08:13,000 --> 01:08:22,160 PHP is going to be evaluated, and then it's going to print out to this file a 1431 01:08:22,160 --> 01:08:26,350 table tow, and then that HTML will be evaluated. 1432 01:08:26,350 --> 01:08:27,810 We're just copying this HTML we had up here. 1433 01:08:27,810 --> 01:08:28,120 Yeah. 1434 01:08:28,120 --> 01:08:29,470 >> AUDIENCE: [INAUDIBLE]? 1435 01:08:29,470 --> 01:08:30,290 >> JASON HIRSCHHORN: Sorry? 1436 01:08:30,290 --> 01:08:31,240 It's right here. 1437 01:08:31,240 --> 01:08:33,590 Fall 2012. 1438 01:08:33,590 --> 01:08:35,970 Don't look at the answers, let's solve it together. 1439 01:08:35,970 --> 01:08:37,330 So we print table row. 1440 01:08:37,330 --> 01:08:38,550 So you're probably in the swing of things. 1441 01:08:38,550 --> 01:08:41,060 What's the next line of code we need to write? 1442 01:08:41,060 --> 01:08:42,926 Assam, give me the next line of code. 1443 01:08:42,926 --> 01:08:46,290 >> AUDIENCE: You need the tf's name. 1444 01:08:46,290 --> 01:08:54,319 Tf open brackets quotation mark name closed brackets. 1445 01:08:54,319 --> 01:08:57,310 >> JASON HIRSCHHORN: Give me their name. 1446 01:08:57,310 --> 01:08:58,540 >> AUDIENCE: You need to print that. 1447 01:08:58,540 --> 01:08:59,790 >> [INTERPOSING VOICES] 1448 01:08:59,790 --> 01:09:01,963 1449 01:09:01,963 --> 01:09:03,430 >> JASON HIRSCHHORN: OK, how do I print it? 1450 01:09:03,430 --> 01:09:04,680 >> [INTERPOSING VOICES] 1451 01:09:04,680 --> 01:09:08,609 1452 01:09:08,609 --> 01:09:10,350 >> JASON HIRSCHHORN: I'm missing something now. 1453 01:09:10,350 --> 01:09:12,470 What am I missing? 1454 01:09:12,470 --> 01:09:13,720 >> AUDIENCE: You need a dollar sign. 1455 01:09:13,720 --> 01:09:15,960 1456 01:09:15,960 --> 01:09:17,210 >> JASON HIRSCHHORN: What else am I missing? 1457 01:09:17,210 --> 01:09:20,100 1458 01:09:20,100 --> 01:09:21,650 All we've printed so far is the tr. 1459 01:09:21,650 --> 01:09:25,589 1460 01:09:25,589 --> 01:09:27,470 >> AUDIENCE: Close the tr after it. 1461 01:09:27,470 --> 01:09:28,720 >> JASON HIRSCHHORN: So we need to close the tr after. 1462 01:09:28,720 --> 01:09:34,390 1463 01:09:34,390 --> 01:09:37,906 Who sees what we're missing on line 16? 1464 01:09:37,906 --> 01:09:39,340 Yeah, Anna. 1465 01:09:39,340 --> 01:09:47,050 >> AUDIENCE: You need to open a td and curly braces. 1466 01:09:47,050 --> 01:09:49,380 >> JASON HIRSCHHORN: And where do we put curly braces? 1467 01:09:49,380 --> 01:09:51,790 >> AUDIENCE: Around the tf name. 1468 01:09:51,790 --> 01:09:53,080 >> JASON HIRSCHHORN: Like this? 1469 01:09:53,080 --> 01:09:55,420 >> AUDIENCE: Yeah. 1470 01:09:55,420 --> 01:09:59,000 And then close the td. 1471 01:09:59,000 --> 01:10:00,250 >> JASON HIRSCHHORN: Like that? 1472 01:10:00,250 --> 01:10:03,370 1473 01:10:03,370 --> 01:10:06,950 >> AUDIENCE: Do you need double quotation marks next to the curly braces? 1474 01:10:06,950 --> 01:10:07,460 >> JASON HIRSCHHORN: Right here? 1475 01:10:07,460 --> 01:10:08,710 No, you don't. 1476 01:10:08,710 --> 01:10:10,820 1477 01:10:10,820 --> 01:10:12,550 So that's exactly right. 1478 01:10:12,550 --> 01:10:12,940 Yeah. 1479 01:10:12,940 --> 01:10:15,290 >> AUDIENCE: So the difference between that and encatenating with dots is, if 1480 01:10:15,290 --> 01:10:18,420 you use dots, you'd have to have the double quotation marks, then a dot, 1481 01:10:18,420 --> 01:10:20,370 then the dot-- 1482 01:10:20,370 --> 01:10:20,520 >> JASON HIRSCHHORN: Correct. 1483 01:10:20,520 --> 01:10:23,800 So you're saying there's an ultimate way of writing this like that. 1484 01:10:23,800 --> 01:10:26,760 1485 01:10:26,760 --> 01:10:28,966 What the concatenation operator in JavaScript? 1486 01:10:28,966 --> 01:10:31,200 >> AUDIENCE: A plus sign. 1487 01:10:31,200 --> 01:10:34,710 You forgot to put the curly brace back. 1488 01:10:34,710 --> 01:10:35,760 >> JASON HIRSCHHORN: Great. 1489 01:10:35,760 --> 01:10:38,850 And there's one more line of code missing. 1490 01:10:38,850 --> 01:10:40,130 Who can give me the last line of code we're missing? 1491 01:10:40,130 --> 01:10:43,940 1492 01:10:43,940 --> 01:10:47,602 >> AUDIENCE: Just the exact same thing, just with house instead of name. 1493 01:10:47,602 --> 01:10:52,960 1494 01:10:52,960 --> 01:10:53,450 Great 1495 01:10:53,450 --> 01:10:54,390 >> JASON HIRSCHHORN: Great. 1496 01:10:54,390 --> 01:10:59,320 And your syntax is exactly right for getting things in an associate array. 1497 01:10:59,320 --> 01:11:04,450 So in the actual quiz, you are actually given up until here. 1498 01:11:04,450 --> 01:11:05,710 So this code was given to you. 1499 01:11:05,710 --> 01:11:07,750 All you had to write were these four lines and remember to 1500 01:11:07,750 --> 01:11:09,190 close the table tag. 1501 01:11:09,190 --> 01:11:11,370 You guys actually did all that and more. 1502 01:11:11,370 --> 01:11:11,810 Yeah. 1503 01:11:11,810 --> 01:11:14,850 >> AUDIENCE: So it would be functionally the same if you just had that all in 1504 01:11:14,850 --> 01:11:17,250 one big print call, right? 1505 01:11:17,250 --> 01:11:19,630 And then just concatenated it on, et cetera? 1506 01:11:19,630 --> 01:11:20,730 >> JASON HIRSCHHORN: Like that? 1507 01:11:20,730 --> 01:11:21,980 >> AUDIENCE: Yeah. 1508 01:11:21,980 --> 01:11:23,810 1509 01:11:23,810 --> 01:11:26,940 It just wouldn't look good if you were looking at it when you're inspecting 1510 01:11:26,940 --> 01:11:28,550 the element on your website, right? 1511 01:11:28,550 --> 01:11:29,800 >> JASON HIRSCHHORN: I agree. 1512 01:11:29,800 --> 01:11:35,410 1513 01:11:35,410 --> 01:11:38,710 If I loaded this webpage, would I be able to see this PHP code, ever? 1514 01:11:38,710 --> 01:11:39,240 >> AUDIENCE: No. 1515 01:11:39,240 --> 01:11:40,080 >> JASON HIRSCHHORN: No. 1516 01:11:40,080 --> 01:11:42,240 And actually, I wouldn't. 1517 01:11:42,240 --> 01:11:43,920 >> AUDIENCE: This isn't HTML, right? 1518 01:11:43,920 --> 01:11:45,000 So you might be able to-- 1519 01:11:45,000 --> 01:11:46,780 >> JASON HIRSCHHORN: So this PHP would be evaluated server side. 1520 01:11:46,780 --> 01:11:51,020 PHP is always evaluated server side, so you're never able to see PHP code. 1521 01:11:51,020 --> 01:11:52,980 >> AUDIENCE: But you'd be able to see the result of the prints. 1522 01:11:52,980 --> 01:11:53,480 >> JASON HIRSCHHORN: Right. 1523 01:11:53,480 --> 01:11:55,510 And it honestly might not put it all on the line. 1524 01:11:55,510 --> 01:11:59,740 It might format it nicely for you, or it might put it on one line. 1525 01:11:59,740 --> 01:12:01,521 Unclear. 1526 01:12:01,521 --> 01:12:03,596 But yes, good point. 1527 01:12:03,596 --> 01:12:06,470 >> AUDIENCE: How come there's no text highlighting for 1528 01:12:06,470 --> 01:12:07,550 any of the PHP commands? 1529 01:12:07,550 --> 01:12:09,370 Because I remember seeing that. 1530 01:12:09,370 --> 01:12:11,620 >> JASON HIRSCHHORN: Because it's a .HTML file up here at the top. 1531 01:12:11,620 --> 01:12:20,390 1532 01:12:20,390 --> 01:12:21,650 There you go. 1533 01:12:21,650 --> 01:12:25,752 1534 01:12:25,752 --> 01:12:28,800 >> AUDIENCE: If we did the initial method with the for loops, right, if we 1535 01:12:28,800 --> 01:12:33,500 wanted to access a tfs, would we do tfs bracket 0 bracket, then 1536 01:12:33,500 --> 01:12:35,180 [INAUDIBLE]? 1537 01:12:35,180 --> 01:12:35,970 >> JASON HIRSCHHORN: You would-- 1538 01:12:35,970 --> 01:12:40,560 so you're saying for the for loop, you would do in dollar sign tfs bracket 1 1539 01:12:40,560 --> 01:12:41,850 or i, right. 1540 01:12:41,850 --> 01:12:46,780 Or dollar sign i close bracket and then square bracket 1541 01:12:46,780 --> 01:12:49,600 double quotes, yeah. 1542 01:12:49,600 --> 01:12:50,640 >> OK, excellent. 1543 01:12:50,640 --> 01:12:53,020 We have one more quick one. 1544 01:12:53,020 --> 01:12:55,090 Seven minutes, so I want to go over this one. 1545 01:12:55,090 --> 01:12:56,160 This is another example. 1546 01:12:56,160 --> 01:12:58,740 We're now a totally other language. 1547 01:12:58,740 --> 01:12:59,990 >> We have some HTML code. 1548 01:12:59,990 --> 01:13:02,480 1549 01:13:02,480 --> 01:13:07,460 It's kind of small on the screen, but I want you to look through it really 1550 01:13:07,460 --> 01:13:11,140 quickly, and can somebody tell me, if I were to load this web page, 1551 01:13:11,140 --> 01:13:12,390 what I would see? 1552 01:13:12,390 --> 01:13:22,710 1553 01:13:22,710 --> 01:13:26,450 Describe everything about this webpage. 1554 01:13:26,450 --> 01:13:28,630 Noah? 1555 01:13:28,630 --> 01:13:30,450 What would I see? 1556 01:13:30,450 --> 01:13:38,140 >> AUDIENCE: Code at the front end of Google with a feel for text and a 1557 01:13:38,140 --> 01:13:39,190 submit button. 1558 01:13:39,190 --> 01:13:41,180 >> JASON HIRSCHHORN: And what would the button say? 1559 01:13:41,180 --> 01:13:42,430 >> AUDIENCE: Submit. 1560 01:13:42,430 --> 01:13:44,620 1561 01:13:44,620 --> 01:13:45,160 Oh, search. 1562 01:13:45,160 --> 01:13:45,840 I'm sorry. 1563 01:13:45,840 --> 01:13:46,830 >> JASON HIRSCHHORN: It would say search. 1564 01:13:46,830 --> 01:13:47,520 Remember, name. 1565 01:13:47,520 --> 01:13:50,550 What do we use name for? 1566 01:13:50,550 --> 01:13:53,774 This name attribute, what's that used for? 1567 01:13:53,774 --> 01:13:55,470 >> [INTERPOSING VOICES] 1568 01:13:55,470 --> 01:13:59,300 >> AUDIENCE: That's its name for when it's clicked? 1569 01:13:59,300 --> 01:14:00,160 >> JASON HIRSCHHORN: That could be. 1570 01:14:00,160 --> 01:14:02,690 But what do we generally see-- why are we giving this name queue? 1571 01:14:02,690 --> 01:14:03,830 Why do we see that? 1572 01:14:03,830 --> 01:14:05,220 Yeah. 1573 01:14:05,220 --> 01:14:08,600 >> AUDIENCE: Doesn't that become index of the super global variable? 1574 01:14:08,600 --> 01:14:12,740 >> JASON HIRSCHHORN: Yeah, generally when this form would submit, and then where 1575 01:14:12,740 --> 01:14:13,500 would this submit to? 1576 01:14:13,500 --> 01:14:14,750 What page? 1577 01:14:14,750 --> 01:14:16,820 1578 01:14:16,820 --> 01:14:18,460 Noah, what page would this submit to? 1579 01:14:18,460 --> 01:14:25,710 1580 01:14:25,710 --> 01:14:27,700 >> AUDIENCE: I'm not sure. 1581 01:14:27,700 --> 01:14:28,920 >> JASON HIRSCHHORN: Where could we can find it? 1582 01:14:28,920 --> 01:14:31,025 Where do you find what page it submits to? 1583 01:14:31,025 --> 01:14:32,850 What line of code? 1584 01:14:32,850 --> 01:14:34,040 >> AUDIENCE: Form action. 1585 01:14:34,040 --> 01:14:34,650 >> JASON HIRSCHHORN: Exactly. 1586 01:14:34,650 --> 01:14:35,130 Action. 1587 01:14:35,130 --> 01:14:37,100 So it submits to the search page. 1588 01:14:37,100 --> 01:14:38,630 Backslash search. 1589 01:14:38,630 --> 01:14:40,140 So that's exactly right. 1590 01:14:40,140 --> 01:14:40,680 What method? 1591 01:14:40,680 --> 01:14:42,090 >> AUDIENCE: Get. 1592 01:14:42,090 --> 01:14:42,490 >> JASON HIRSCHHORN: Get. 1593 01:14:42,490 --> 01:14:43,420 Exactly. 1594 01:14:43,420 --> 01:14:44,490 So we read this. 1595 01:14:44,490 --> 01:14:45,180 This is going to be a form. 1596 01:14:45,180 --> 01:14:45,910 You're exactly right. 1597 01:14:45,910 --> 01:14:50,340 Two things on the form, the title of the page and the top would be Google. 1598 01:14:50,340 --> 01:14:54,270 >> So here are two questions you should be able to answer about this page. 1599 01:14:54,270 --> 01:15:01,760 If this HTML lives at this website and the user inputs bug into this text 1600 01:15:01,760 --> 01:15:06,900 field right here, what URL will the user find herself upon 1601 01:15:06,900 --> 01:15:08,150 submitting the form? 1602 01:15:08,150 --> 01:15:10,980 1603 01:15:10,980 --> 01:15:12,510 >> So we have this right here. 1604 01:15:12,510 --> 01:15:13,720 I'm going to go back to this page, though. 1605 01:15:13,720 --> 01:15:16,980 I'll write up this first part. 1606 01:15:16,980 --> 01:15:18,230 Can everybody see over here? 1607 01:15:18,230 --> 01:15:30,620 1608 01:15:30,620 --> 01:15:32,906 OK, Mario, you think you know? 1609 01:15:32,906 --> 01:15:34,700 What page? 1610 01:15:34,700 --> 01:15:37,630 >> AUDIENCE: Backslash search. 1611 01:15:37,630 --> 01:15:38,880 >> JASON HIRSCHHORN: I'm going to move down here. 1612 01:15:38,880 --> 01:15:44,800 1613 01:15:44,800 --> 01:15:49,155 OK, backslash search question mark q equals bug. 1614 01:15:49,155 --> 01:15:53,560 1615 01:15:53,560 --> 01:15:55,165 Anybody have a different suggestion? 1616 01:15:55,165 --> 01:15:57,910 1617 01:15:57,910 --> 01:15:59,160 Yeah. 1618 01:15:59,160 --> 01:16:01,700 1619 01:16:01,700 --> 01:16:03,740 >> So how do we get this? 1620 01:16:03,740 --> 01:16:05,520 Well, we've seen this before. 1621 01:16:05,520 --> 01:16:07,170 And you came up with this earlier. 1622 01:16:07,170 --> 01:16:08,870 You were right, Noah, that the action is telling us what 1623 01:16:08,870 --> 01:16:11,700 page we're going to. 1624 01:16:11,700 --> 01:16:12,820 >> We also know what method. 1625 01:16:12,820 --> 01:16:13,420 We're doing get. 1626 01:16:13,420 --> 01:16:17,040 And the difference between get and post is that get displays in the URL 1627 01:16:17,040 --> 01:16:18,490 and post doesn't. 1628 01:16:18,490 --> 01:16:22,760 So if I wrote post right there in the method, what would be different? 1629 01:16:22,760 --> 01:16:24,250 >> AUDIENCE: It would just be slash search. 1630 01:16:24,250 --> 01:16:25,400 >> JASON HIRSCHHORN: It would just be slash search. 1631 01:16:25,400 --> 01:16:27,400 Nothing over here would happen. 1632 01:16:27,400 --> 01:16:30,030 But because it's a get, the URL is displayed as follows. 1633 01:16:30,030 --> 01:16:35,140 First we see a question mark and we see the name and the value. 1634 01:16:35,140 --> 01:16:42,730 Say there was one other text field and I gave it a name of r and I input a 1635 01:16:42,730 --> 01:16:45,220 value, caterpillar. 1636 01:16:45,220 --> 01:16:48,560 What would this now look like? 1637 01:16:48,560 --> 01:16:52,040 I have one more text field, I give a name of r and a value of caterpillar. 1638 01:16:52,040 --> 01:16:56,990 >> AUDIENCE: After bar you'd have the ampersand caterpillar. 1639 01:16:56,990 --> 01:16:58,380 >> JASON HIRSCHHORN: That's not ampersand. 1640 01:16:58,380 --> 01:17:00,500 >> AUDIENCE: Or just whatever the and symbol. 1641 01:17:00,500 --> 01:17:01,330 >> JASON HIRSCHHORN: Yeah, no. 1642 01:17:01,330 --> 01:17:03,700 You were right, I was wrong. 1643 01:17:03,700 --> 01:17:05,660 That's like a g. 1644 01:17:05,660 --> 01:17:06,910 >> AUDIENCE: Caterpillar. 1645 01:17:06,910 --> 01:17:08,840 1646 01:17:08,840 --> 01:17:11,090 r equals caterpillar, sorry. 1647 01:17:11,090 --> 01:17:13,970 1648 01:17:13,970 --> 01:17:14,700 >> JASON HIRSCHHORN: Is there no r in there? 1649 01:17:14,700 --> 01:17:16,680 >> AUDIENCE: No, there is. 1650 01:17:16,680 --> 01:17:18,030 >> JASON HIRSCHHORN: We'll talk about that after class. 1651 01:17:18,030 --> 01:17:18,930 That's exactly right. 1652 01:17:18,930 --> 01:17:20,530 So the and is correct. 1653 01:17:20,530 --> 01:17:23,430 And then you could have many of these, and they would all be concatenated 1654 01:17:23,430 --> 01:17:24,950 together with that and. 1655 01:17:24,950 --> 01:17:25,900 So that's exactly right. 1656 01:17:25,900 --> 01:17:27,700 >> There's one more question. 1657 01:17:27,700 --> 01:17:30,676 Sketch this HTML's DOM, starting with document. 1658 01:17:30,676 --> 01:17:33,330 1659 01:17:33,330 --> 01:17:34,570 We could do that in two minutes. 1660 01:17:34,570 --> 01:17:36,790 We'll do it over here. 1661 01:17:36,790 --> 01:17:38,040 I'll go back to this webpage. 1662 01:17:38,040 --> 01:17:40,630 1663 01:17:40,630 --> 01:17:42,160 OK, we start with document. 1664 01:17:42,160 --> 01:17:49,698 1665 01:17:49,698 --> 01:17:52,090 >> What's next? 1666 01:17:52,090 --> 01:17:53,910 So when you're reading through-- 1667 01:17:53,910 --> 01:17:54,540 >> AUDIENCE: HTML. 1668 01:17:54,540 --> 01:17:55,790 >> JASON HIRSCHHORN: HTML is next. 1669 01:17:55,790 --> 01:17:57,850 We're going to go tag by tag. 1670 01:17:57,850 --> 01:18:00,890 What's after HTML? 1671 01:18:00,890 --> 01:18:01,550 >> AUDIENCE: Head. 1672 01:18:01,550 --> 01:18:02,800 >> JASON HIRSCHHORN: Head. 1673 01:18:02,800 --> 01:18:05,090 1674 01:18:05,090 --> 01:18:08,520 What's after head? 1675 01:18:08,520 --> 01:18:09,770 >> AUDIENCE: Title. 1676 01:18:09,770 --> 01:18:11,880 1677 01:18:11,880 --> 01:18:12,560 >> JASON HIRSCHHORN: Title. 1678 01:18:12,560 --> 01:18:14,740 And title has a value of Google, but I'm not going to 1679 01:18:14,740 --> 01:18:16,240 write that in for now. 1680 01:18:16,240 --> 01:18:18,750 OK, where does body go? 1681 01:18:18,750 --> 01:18:20,890 >> AUDIENCE: Also coming off of the HTML. 1682 01:18:20,890 --> 01:18:21,490 >> JASON HIRSCHHORN: Exactly. 1683 01:18:21,490 --> 01:18:22,820 Body comes off of here. 1684 01:18:22,820 --> 01:18:25,970 1685 01:18:25,970 --> 01:18:30,330 Does everybody see why that's the case? 1686 01:18:30,330 --> 01:18:32,970 You should probably be able to figure this out, too, even if I didn't have 1687 01:18:32,970 --> 01:18:33,665 this nice indentation. 1688 01:18:33,665 --> 01:18:37,680 >> The indentation sort of gives it away, but you can see that the head tag has 1689 01:18:37,680 --> 01:18:41,240 been closed, which means we probably can't go down here. 1690 01:18:41,240 --> 01:18:43,460 We need to go back up to whatever was right before the head 1691 01:18:43,460 --> 01:18:44,730 tag, or under that. 1692 01:18:44,730 --> 01:18:46,720 We're even with the head tag. 1693 01:18:46,720 --> 01:18:48,560 >> And under body goes form. 1694 01:18:48,560 --> 01:18:50,300 Under form, there are two inputs. 1695 01:18:50,300 --> 01:18:53,330 1696 01:18:53,330 --> 01:18:54,420 OK. 1697 01:18:54,420 --> 01:18:55,490 That's all I got. 1698 01:18:55,490 --> 01:18:56,980 Quiz 1 is tomorrow. 1699 01:18:56,980 --> 01:18:58,350 I'm so excited for you guys. 1700 01:18:58,350 --> 01:18:59,690 It's going to be a blast. 1701 01:18:59,690 --> 01:19:00,250 >> If you have-- 1702 01:19:00,250 --> 01:19:00,600 >> AUDIENCE: [APPLAUSE] 1703 01:19:00,600 --> 01:19:02,460 >> JASON HIRSCHHORN: Oh stop, stop. 1704 01:19:02,460 --> 01:19:04,520 But no, I'm kidding. 1705 01:19:04,520 --> 01:19:07,220 If you have any questions, right after section, I'll be outside. 1706 01:19:07,220 --> 01:19:11,700 If you have any questions tonight, feel free to call, email, gchat, 1707 01:19:11,700 --> 01:19:12,740 carrier pigeon me. 1708 01:19:12,740 --> 01:19:13,950 Good luck tomorrow. 1709 01:19:13,950 --> 01:19:16,220 Have a wonderful Thanksgiving break, if I don't see you before then. 1710 01:19:16,220 --> 01:19:19,320 And I will see you after Thanksgiving on Tuesday for our final 1711 01:19:19,320 --> 01:19:20,295 section party ever. 1712 01:19:20,295 --> 01:19:21,545 >> AUDIENCE: [INAUDIBLE]. 1713 01:19:21,545 --> 01:19:25,270 1714 01:19:25,270 --> 01:19:25,790 >> JASON HIRSCHHORN: Great. 1715 01:19:25,790 --> 01:19:28,900 OK, I'll see you guys next week, or in two weeks. 1716 01:19:28,900 --> 01:19:30,150 And good luck tomorrow. 1717 01:19:30,150 --> 01:19:32,203