Lesson 5 Notes - Intro to Computer Science Lesson 05 Notes...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Intro to Computer Science Lesson 05 Notes How Programs Run Introduction DE: At the end of Unit 4, we built a search index that could respond to queries and would do this by going through each entry one at a time, checking if the keyword matched the word we were looking for, and then responding with a result for that. I wanted to ask Gabriel Wienberg, the creator of DuckDuckGo, how well that approach will work if we have a large index with lots of queries. GW: You'll find that with a large index with lots of queries, it will be too slow. A typical search engine should respond in under a second and often times much faster. But with that algorithm, having to go through each link like that one after the other, you could be on the order of seconds or even longer. So what we're going to learn in this unit is how to make this much faster. Making Things Fast So welcome to Unit Five. The main topic for this unit is trying to understand the cost of running programs. So far, we haven't really worried about this. We've been very happy to write code. If we get the correct result, that's a great thing. But once we start making programs bigger, worrying about programs that do more things, running on larger inputs, we have to start thinking about the cost of running our programs. And this question of what it costs to evaluate an execution is a very important problem in computer science. In some sense, it's one of the most fundamental problems. Many people spend their whole careers working on this. And it's a problem called Algorithm Analysis. I Copyright © 2014 Udacity, Inc. All Rights Reserved.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
haven't yet explained what an algorithm is. But you've actually written many of them already. So an algorithm is a procedure that always finishes. A procedure is just a well-defined sequence of steps. It has to be defined precisely enough that it could be executed mechanically. So to be a procedure, it has to be something that can be executed without any thought. And we're mostly interested in procedures that can be executed by computers. But the important part of what makes it a procedure is that the steps are very precisely defined and don't require any thought to execute. To be an algorithm, it has to always finish, and we've pointed out already that this is a very tough problem to figure out whether a program will finish. In general, it's not possible to answer that question, but for many specific programs it is, and in order for a program to be an algorithm, we have to know that it always finishes, and it always produces a correct result. So once we have an algorithm, well, we know we have a well-defined sequence of steps, so we can reason about what will happen on any in always produce the correct result. So, then we can think a algorithm on some input. So how should we think about c cost is quite different from how most people think about about cost, well, if you've got a specific object, let's say, y car. It doesn't quite look like a cool car, and it's got a cost $25,000 car, and you have some other car. So you have on costs you get that car. You could another car that would b
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern