## Subtitles section Play video

• the primary purpose is video.

• Syria's gonna be for analyzing not just algorithms, but also primarily pieces that are gonna be, you know, let's not just in computer science, but also for interviews.

• And then we're gonna be starting up to something called the Big O so really quickly we're gonna be doing this all in the Jupiter notebook, primarily because it's not that difficult enough that we have to use pi charm.

• And it's also a little bit cleaner looking.

• So I analyzed algorithms in the first place when algorithm don't get never spoke a word.

• It's just procedure or formula for solving a problem.

• Some of them are so useful that we've given them names like Merge sort of bubbles sort et cetera.

• And then one of the important things were gonna come across you can see very quickly is how can we compare the algorithms, you know, which is better, and by better it's gonna be relative term to the task at hand.

• But typically there's gonna be two avenues for analyzing if an algorithm is better than another and that's going to be either by speed, time of completion on, that's gonna go into its scalability.

• and also memory, its size, allotment and its requirements and so forth.

• So really quick somethin.

• So in this 1st 2nd Cody said, imagine keeping dysfunction.

• This was just to finding a function called some of one.

• It's taking one argument, and so then we have final Sum equal zero.

• So we have an object Final sum ever, given the assignment of zero, it says for X and range and plus one.

• So we have a for loop here.

• Range is gonna be whatever define it for in terms of the ends and plus one equals final, some equals fun, awesome plus X And then we're returning the final sum.

• So I'm just going thio shift, enter.

• So that actually loads into the Jupiter notebook.

• And then I have hear someone calling five of the argument.

• You'll see that it prints up 15.

• So what this did was with the object having the argument of five and the formula essentially the algorithm for this was for X and rain.

• So for each number in range and plus one and was five, so in six you remember for range started zero.

• So we had to add that one of wanted to really get five actual numbers.

• So zero is not gonna have any implication for addition on the final sum of starting at zero.

• So if we did five times four, we're gonna have 99 plus three is 12.

• 12 plus two is 14 14 plus one is 15.

• So, of course we got the answer to be 15th.

• That's appropriate.

• So let's see what this is all going towards anyway.

• So, again, this is, uh, function that we've created to finding a sum of one.

• And we got a result of 15 when Ann Nichols five.

• I'm going to go down here and now for this one.

• And let's assume that you gave me this function.

• You called it some to also taking only one argument of end and you instead of doing a four low Penis returning and times and plus one divided by two.

• And let's see what we get.

• I'm gonna shift into through that as well and same argument of five, and we also get 15 same exact function.

• If you actually did this math by hand, of course, Pem dos is gonna hold place, so parentheses.

• You're always gonna be first, so you would have had five plus one, which is going to be 66 times five is 30 35 by two is going to be 15.

• So what's the point of this?

• Essential?

• We got the same answer with two very different functions that's essential.

• That that's that's the point of this.

• So this is my function I created, and this is the one that you created, both getting the same result.

• So function one is someone's gonna complain about that, right?

• Nephew.

• So function of someone.

• It's using a four loop to interpret it curative Lee at across our range of plus one.

• So here's our four lope and we're just iterating over the range that was dictated by the input end.

• And it's adding across that range.

• Number two is simply just taking advantage of a formula.

• It's a formula bases off a problem.

• Both of these are technically algorithms because remember the algorithm is this a procedure or formula for solving a problem?

• So we're solving a problem, and here was something problem.

• This is just more formula base, and this is an iterated four loop that we're running.

• So now the question is gonna come.

• How do we compare them?

• How do we determine whose function is better mine or yours?

• And that's gonna come relative to what it is you're trying to determine.

• Defines is better.

• So we have to objectively be able to compare them.

• And the two places.

• The two avenues I mentioned before that we could do the four is memory, which is space allocation within the computer or the time to run that much time it's gonna take to actually run that software.

• So we're going to use built in magic magic commands in the note.

• The Jupiter notebook.

• Sometimes I might call it I Python.

• That's the old connotation.

• Expect that it was just Python and now it's multiple languages.

• So they called Jupiter Notebook.

• So first of this, his is a magic command using the percent side time it and I'm saying, I want you to time it for the sum of one function with an end of 100.

• So I'm gonna shift into that and right now what it's doing, it's doing that for loop.

• So there we go.

• We got 100,000 loops.

• Best of 33.7 for microseconds, poor loop, and then I'm going to do the same magic time at some two with 100 z input.

• And then d'oh, it's doing the computation Now.

• Took a second there, depending on your computer is going to determine if it happens faster or slower.

• So for the same end of 100 which we know that they're gonna give me the same answer.

• And you can ignore this for right now that's just talking about cashing best of 344.

• But now this is nanoseconds.

• So and I put down here just for those who may not know Micro, which is up top here is 10 to the minus six.

• Nana was 10 to the minus nine.

• So that means Nano is a smaller number by a factor of three.

• And so this is faster.

• So in the two different functions, we had function of someone of function of some too for the same end.

• My algorithm, your algorithm, your algorithm was a function was much, much faster.

• You were on nanoseconds.

• I was on microseconds for time of completion.

• But now that's not necessarily the end Albil because that's the time of completion on my computer, your computer, the time of completion might be faster.

• Slower now, of course.

• Granted, we're talking micro nano seconds.

• That difference can get very large, and we have much larger inputs to deal with, and some systems will be faster or slower.

• But at the end of the day, regardless, four lives here was gonna be slower, and that's what we try to avoid them, and especially machine and artificial intelligence.

• So now that we have that, um, I have your smallest number is obviously faster, we know that.

• So we can't rely on just time to run, because again, all computers, a different hardware is gonna be different somewhere fast and others.

• We want this to be hardware independent, and that's one of the big takeaways because, as you know, hardware is constantly changing.

• So how come we objectively determine if one function is faster or slower, or rather, is better or worse than that of the function?

• If we can't use the time parameter per se because of the objective nature of different futures?

• Well, that's where the big O comes in.

• So the big O is a way that we can objectively compared the efficiency of those two algorithms.

• So we're gonna get the number of assignments of each algorithm.

• There's some key phrases here, but we're gonna run through this.

• But I want you to be cognitive.

• So we're gonna compare the number of assignments if you that each outgrow them.

• Makes four has to undergo.

• So for the original someone function, it's I'm going to read this and I'll go back up to it and show you what I mean.

• The original someone functional.

• Corrina, Simon End.

• Plus one times we can see this from the range based function.

• This meeting will assign the final some variable M plus one times we convince it for the problem of and size.

• In this case, just a number end.

• This function will take one plus and steps, and this one's gonna become meaningless.

• So going back up to function number one or someone what it's saying here is that the allocation that this is going to that this is gonna require in terms of an assignment, it's only in the assignment.

• Is this so if my end is one, it's gonna have to assignments is gonna have the assignment of one and then the assignment of zero, because again, we're dealing with indexing was here on its ranging If my aunt is three and I'm gonna have four it's going to be the assignments gonna be still be and plus one because whatever.

• Then it's gonna be it's gonna be linear is the point that we're gonna be looking at here.

• But there's only one assignment that's necessarily going on within this and a final first assignment is zero and the Met assignments gonna keep changing based on an order of end.

• The end notation allows us to compare the solutions and algorithms relative to the size of the problem.

• So since someone 10 and some one of 100,000 we take very different times to run.

• But using the same algorithm, we can also note that end grows very large.

• The plus one doesn't have much effect.

• That's almost referring before some of these constant numbers.

• Essentially, when you start to get the numbers like infinity or if you're familiar with calculus, make it's the limits.

• The constance.

• The constant numbers just drop off.

• They no longer have a real effect on the on the ultimate coating.

• You'll see that in just a minute.

• So how can we how Can we still quantify this?

• How can we still compare the functions?

• And that's where big O notation it comes in.

• It's describing how quickly the runtime will grow relative to the input as the implicates arbitrarily large.

• Um, And again, this is how we're gonna measure one algorithm over another or even one you know, different coding aspects, like using numb pine.

• An instance where so it could be active a lot faster than if you're using a built in list sequence and python using data frames instead else utilizing pandas.

• So it's all the big O when I want you to put your head.

• It's how well can it scale as the data increases?

• Because Big O has a lot to do with scaling.

• That's Callen can either be in time or can be in memory.

• So we're comparing how quickly the runtime is going to grow, not the exact run times since those are gonna depend on the hardware.

• So at least this way I could know it doesn't matter the system.

• If I have two different algorithms, I can tell you that one algorithm is going to have some element of time, and this other algorithm is going to have a comparatively different relative amount of time.

• Regardless of the hardware, one's gonna be faster than the other.

• If I can see the code and I do the big O notation So it's the end gets arbitrarily large.

• We're only were about the terms that we grow.

• The fastest is that gets large.

• So essentially you're looking at an algorithm.

• And if you're trying Thio, which we're gonna get down to just a second, you can determine which element in that code is the driving factor.

• Which one?

• Still, which one's gonna actually impose the limiting behavior on the execution of that code?

• Well, that's gonna be your big go on.

• Everything else essentially gonna drop off and in math, that's this.

• This idea is called asymptomatic analysis, which is just describing living in behavior.

• So it's kind of looking at the whole picture, So we're gonna get to this guy in a second.

• So a synthetic analysis is looking at this return here and pretty much saying who is the limiting factor in here?

• Who's gonna limit what my end is going to be able to?

• D'oh, Which one of these guys is gonna mess with scaling the most or of the most impact of the least impact on scaling.

• Then you can go from there.

• So again, which part of the album has the greatest effect on the final answer?

• Which part of the Argo is the real bottleneck, which is the limiting factor?

• As for this intact, someone could be said to be This is the notation here.