As for the third topic. A randomized algorithm is one that, in some sense,

flips coins while it executes. That is, a randomized algorithm will actually have

different executions if you run it over and over again on a fixed input. It turns

out, and this is definitely not intuitive, that allowing randomization internal to an

algorithm, often leads to simple, elegant, and practical solution to various

computational problems. The canonical example is randomized quick sort, and that

algorithm and analysis we will cover in detail in a few lectures. Randomized

primality testing is another killer application that we'll touch on. And we'll

also discuss a randomized approach to graph partitioning. And finally

we'll discuss how randomization is used to reason about hash functions and hash maps.

One of the themes of this course, and one of the concrete skills that I hope you

take away from the course, is, literacy with a number of computational primitives

for operating on data, that are so fast, that they're, in some sense, essentially

free. That is, the amount of time it take to invoke one of these computational

primitives is barely more than the amount of time you're already spending just

examining or reading the input. When you have a primitive which is so fast, that

the running time is barely more than what it takes to read the input, you should be

ready to apply it. For example, in a preprocessing step, whenever it seems like

it might be helpful. It should just be there on the shelf waiting to be applied

at will. Sorting is one canonical example of a very fast, almost for-free

primitive of this form. But there are ones that operate on more complex data as well.

So recall that a graph is a data structure that has, on the one hand, vertices, and

on the other hand, edges. Which connects pair of vertices. Graphs model, among any

other things, different types of networks. So even though graphs are much more

complicated than mere arrays, there's still a number of blazingly fast primitives

for reasoning about their structure. In this class we'll focus on primitives for

competing connectivity information and also shortest paths. We'll also touch on how some primitives have been

used to investigate the structure of information in social networks. Finally,

data structures are often a crucial ingredient in the design of fast

algorithms. A data structure's responsible for organizing data in a way that supports

fast queries. Different data structures support different types of queries. I'll

assume that you're familiar with the structures that you typically encounter in

a basic programming class including arrays and vectors. Lists, stacks, and queues.

Hopefully, you've seen at some point both trees and heaps, or you're willing to read

a bit about them outside of the course, but we'll also include a brief review of

each of those data structures as we go along. There's two extremely useful data

structures that we'll discuss in detail. The first is balanced binary search trees.

These data structures dynamically maintain an ordering on a set of elements, while

supporting a large number of queries that run in time logarithmic in the size of

the set. The second data structure we'll talk a fair bit about is hash tables or

hash maps, which keep track of a dynamic set, while supporting extremely fast

insert and lookup queries. We'll talk about some canonical uses of such data

structures, as well as what's going on under the hood in a typical

implementation of such a data structure. >> There's a number of

important concepts in the design and analysis of algorithms that we won't have

time to cover in this five week course. Some of these will be covered in the

sequel course, Design and Analysis of Algorithms II, which corresponds to the

second half of Stanford's ten week course on this topic. The first part of this

sequel course focuses on two more algorithm design paradigms. First of

all, the design analysis of greedy algorithms with applications to minimum

spanning trees, scheduling, and information theoretic coding. And

secondly, the design analysis of dynamic programming algorithms with example

applications being in genome sequence alignment and the shortest path protocols

in communication networks. The second part of the sequel course concerns NP complete

problems, and what to do about them. Now, NP complete problems are problems that,

assuming a famous mathematical conjecture you might have heard of, which is called the

"P not equal to NP" conjecture, are problems that cannot be solved under this

conjecture by any computationally efficient algorithm. We'll discuss the

theory of NP completeness, and, with a focus on what it means for you as an

algorithm designer. We'll also talk about several ways to approach NP complete

problems, including: fast algorithms that correctly solve special cases; fast

heuristics with provable performance guarantees; and exponential time

algorithms that are qualitatively faster than brute force search. Of course there

are plenty of important topics that can't be fit into either of these two five-week

courses. Depending on the demand, there might well be further courses on more

advanced topics. Following this course is going to involve a fair amount of time and

effort on your part. So it's only reasonable to ask: What can you hope to get

out of it? What skills will you learn? Well. Primarily, you know, even though

this isn't a programming class per se, it should make you a better programmer.

You'll get lots of practice describing and reasoning about algorithms, you'll learn

algorithm design paradigms, so really high level problem-solving strategies that are

relevant for many different problems across different domains, and tools for

predicting the performance of such algorithms. You'll learn several extremely

fast subroutines for processing data and several useful data structures for

organizing data that can be deployed directly in your own programs. Second,

while this is not a math class per se, we'll wind up doing a fair amount of

mathematical analysis. And this in turn will sharpen your mathematical analytical

skills. You might ask, why is mathematics relevant for a class in the design and

analysis of algorithms, seemingly more of a programming class. Well let me be clear.

I am totally uninterested in merely telling you facts or regurgitating code

that you can already find on the web or in any number of good programming books. My

goal here in this class, and the way I think I can best supplement the resources

that you probably already have access to is to explain why things are

the way they are. Why we analyze the algorithms in the way that we do, why

various super fast algorithms are in fact super fast, and so on. And it turns out

that good algorithmic ideas usually require nontrivial mathematical analysis

to understand properly. You'll acquire fundamental insights into the specific

algorithms and data structures that we discuss in the course. And hopefully, many

of these insights will prove useful, more generally, in your other work. Third, and

perhaps the most relevant for those of you who work in some other discipline: this

course should help you learn how to think algorithmically. Indeed after studying

algorithms it's hard enough not to see them pretty much everywhere, whether you

are riding an elevator, watching a flock of birds, buying and selling stocks out of

your portfolio, even watching an infant learn. As I said in the previous video

algorithm thinking is becoming increasingly useful and prevalent if you

are outside of computer science and technology like in biology, statistics and

economics. Fourth, if you're interested in feeling like a card carrying computer

scientist, in some sense, then you'll definitely want basic literacy in all of

the topics that we'll be covering. Indeed, one of the things that makes studying

algorithms so fun, is, it really feels like you're studying a lot of the greatest

hits from the last 50 years of computer science. So, after this class, no longer

will you feel excluded at that computer science cocktail party when someone cracks

a joke about Dijkstra's Algorithm. Now you'll know exactly what they mean.

Finally, there's no question that studying this material is helpful for technical

interview questions. To be clear, my sole goal here is to teach you algorithms, not

to prepare you for interviews, per se. But over the years, countless students of mine

have regaled me with stories about how mastering the concepts in this class

enabled them to ace every technical question they were ever asked. I told you,

this is fundamental stuff. So, what do I expect from you? Well, honestly, the

answer is nothing. After all isn't the whole point of a free online class like

this one that anyone can take it and devote as much effort to it as they like.

So that said, as a teacher it's still useful to have one or more canonical

students in mind. And I thought I'd go ahead and be transparent with you about

how I'm thinking about these lectures. Who I have in mind that I'm teaching to. So

again, please don't feel discouraged if you don't conform to this canonical

student template. I'm happy to have the opportunity to teach you about algorithms

no matter who you are. So first, I have in mind someone who knows at least some

programming. For example, consider the previous lecture. We talked about a

recursive approach to multiplying two numbers and I mentioned how in certain

mathematical expression, back then we labeled it star and circled it in green.

How that expression naturally translated into a recursive algorithm. In particular,

I was certainly assuming that you had some familiarity with recursive programs.

If you feel comfortable with my statement in that lecture, if you feel like you

could code up a recursive integer multiplication algorithm based on the high

level outline that I gave you, then you should be in good shape for this course.

You should be good to go. If you weren't comfortable with that statement, well, you

might not be comfortable with the relatively high conceptual level at which

we discuss program in this course. But I encourage to watch the next several videos

anyway, to see if you get enough out of them to make it worth your while. [sound].