Alright guys, so I'm going to explain to you guys how Asymptotic complexity works because a lot of people don't actually understand time complexity as much as they think they do They just see like a for loop and be like, oh, this is o of n or whatever Oh, there's the two for lips is o n squared or whatever. So first of all, let's say I give you an algorithm Let's say you found out something really cool. I don't know right now. There's the coronavirus, right? Let's say you found out a way to track every single person's corona virus So many people out there with corona virus, right? You're trying to track them down, right? And you finally develop developed this novel algorithm that just Able to track down all these people Well, then how can we measure the speed of this algorithm on other types of devices, right? Because like one device could be way faster than the other one could be processing way faster and like faster CPU time might take Some slower machines might take slower, right? So what do we do? Well, what do we do first? We pretty much we're gonna do is that we're gonna give you a bunch of data points Okay, and then we are going to calculate the time it takes for every single data point So let's say I give you a certain number of data points. This is called n whatever the input side That's like 10 data points to 20 data points Whatever and you are going to calculate the time for every single one you measure it You measure the time you measure how long it takes for this algorithm to run And then what do we do we graph every single data point with it whatever time? So like let's say we might get something like this. Alright, maybe your algorithm does something like that Okay, this is after when we graph everything. Well, we can't really analyze this, right? We can't find the speed of this, right? So what do we do? We approximate it, right? We approximate it. We create a mathematical approximation function using your algorithm So then it might look something like that. Let's call this f of n. It's connect all the dots It might look something like that.  I don't know some weird starting value Tan inverse of whatever pi or something like 24 or whatever that this Function might have some ridiculous crazy thing and what can we do with this very hard to Analyze some crazy constants that you have interfering with this this algorithm. So what do we do? What computer scientists do is that they find a boundary, okay? They're going to bound whatever function between two lines. Let's say this is your function We're going to bound it between here and we're going to bound it between here So if we bound this function between these two lines It is much easier much much easier to analyze it and when our input size Becomes way too much if I input size goes one million users or a thousand or hundred thousand or a billion people It's much easier find the time it takes to do this You might be able to change your algorithm and do whatever it wants and let's call this first point c1 G of n c1 is just one constant of this Function g of n that we bounded it to and then what we do is we try to find a function So you could bound it to such that there's two exists two constants as it's between so it's like the the exact same Function as the original one this and this except there's just a different constant So then if we're able to bound it between these two lines exact same function just with different constants It is much easier to analyze if you think about it. So what do we call this? We call this theta notation So f of n is now bounded between theta of g of n So what does that mean? It means that it is within a constant factor of a tightly bounded of f of n So that means that g of n is a asymptotically tight bound for f of n with this first of all We know that g of n cannot be negative. Okay, if it's negative that doesn't make much sense Even this function just doesn't make much sense because if you input million users your time It takes to run is going to increase if it's negative you that means you either run on a super computer or something or some it It gets faster while there's more data points to process that doesn't make any sense So we know that this has to be non-negative. Okay, it has to be positive That's what theta g of n mean theta g of n is equal to f of n if there's exists c1 c2 Positive constant and n zero n zero is all these a starting point where all these connected to each other Okay, such that it's between zero c1 g1 zero c1 g and Zero and f of n so f of n is between these we're all and that's greater than or equal to n zero This means such that by the way, you don't know the notation theta g of n is equal to f of n if there exists two Constants c1 c2 that bounds it between it c1 times g of n is less than or equal to f of n And f of n is less than or equal to c2 times g of n. Okay, that's what this data notation means, okay? So and you could figure out all the the values of what it is and but let's look back at this equation Let's look at these constants as you could see if you were to continually graph many many data points that they figured out You could actually see that most of these values Constants that engine inverse pi and sine square 3.2 pi those don't matter anymore as we reach in more infinity infinity what really matters is that the constants that bounds G of n and c2 a g of n. Okay, that's what really matters So we could actually throw those away so these constants don't matter anymore So we actually could just call it theta of n and the reason why it's theta of n is because there exists two constants That is going to bound n towards f of n function. Okay So f of n is is approximate to theta of n, right? So like in this case our g of n would be just n a function of one straight line and that's where it bounds this function There exists two constants that we could bound are the regular straight line towards this f of n of this crazy ridiculous function Okay, so that's that that's what this means. Okay. Now. Let's talk about o notation so let's say we graph the same time function as before I give you a bunch of input values and you graph how long your algorithm takes and then your Function looks something like this. Okay, if I could find another function that bounds it above an upper bound function of this Function f of n then I could analyze this right so before here We've tried to found two constants that could bound between this function g of n But this time we are just trying to find one function that could bound this function towards So let's call this let's call the function look like that. Okay, and this function will call it g of n And it's just one constant multiplied well We call g of n asymptotic big o notation big o notation o of g of n is going to equal to f of n if there exists a constant c 1 multiplied c 1 and And zero and zero just like a starting point here We'll call it where they both cross and zero such that zero is between f of n and f of n is less than or equal to c G of n for all and Is greater than equal to n zero. Okay, so when we say this is a big o of n square or big o of n it means that there exists a a Like like if we say the time complexity is big o So this is big o notation big o when we say something is big o of n. It means that there exists a constant multiplied by n that bounds this Your algorithms time function above it. Okay, so there exists a function Whatever this function is as it approaches infinity, right that multiplies by a constant bounds it above your algorithms Time function. Okay, that's what they mean. So this big o means is the upper bound limit for this function And as you can see here initially your big o function might actually be not as efficient as your Normal function as you can see here because like some of this might actually have increased faster or Slower than your original function. So big o notation might not actually be best case To work with sometimes for small values for I'm saying for small value, right? Because it's like the rate of increase. Yeah, it's basically what the big o notation means You can also say like f of n so when okay, so when f of n is equal to g of big o of g of n You can also write it as is a member of g of n o of g of n o of g of n So what they're saying is that here what they mean is using set theory It's just a subset of its beta g of n is a subset of O of g of n because it's a small part of it This is bounded above and this this is squeezed between two constants So a small part is gonna be a a subset of the larger part. Okay, that's what that means Big o notation means it's there's an upper bound tight limit your time complexity is so that your time of your algorithm That's what it means. There's also another case where we could think about omega notation I think I think my good notation is a lower bound omega notation I'll draw it out an omega notation looks like this. This is your time function and this this is omega So it's bounded below if you have a lower function technically you could write any function That's actually bounded below if you could just find a constant for this means and Most but most of the time we don't really care about this because like we really care about the like the lower bound doesn't really mean much Sometimes it does. I'll just write the mathematical notation g of n is equal to f of n if there exists c 1 n 0 such that 0 less than c g n Which is less than f of n all n greater than equal n not and not it's just like where they intersect Yeah, that's what this big omega notation means So another thing we could think about is a little old notation little o notation So sometimes you find a function that is actually not as tight as your f of n function Let's say the bound to n square is equal to big o of n square, right? This is a tight function, right if you are to bound it between the line like an upper bound We know that this is 2n square is bounded by n square, right? So there exists a a constant c such that c times n square is above 2n square, right? So that that is a tight bound, but sometimes it's not as Asymptotically bound so like you could say that 2 of n is equal to o of n square You could write that I mean, it's not it's not wrong. There might exist a function like a time constant multiply by n square that is going to be Above 2n, right? You could you could write that it's not tight. It's not tight. It's not like a tight bound, right? What do we do? We use a little o notation. So little o o notation is To describe a upper bound that is not tight like it's not going to squeeze between it This is how you mathematically to find it g of n f of n Positive c greater than zero there exists exists and n not the beginning one greater than zero such that Zero is less than equal to f of n There's less than c g of n for all And that is better than equal to n not so example 2n is Little o of n square, right? There exists a constant multiply by n square that is Above 2n and it's not a tight like it's not a tight bound, but you cannot say 2n square of this like this doesn't make sense This this this function is bounded tightly n square is bounded tightly the 2n square like there It does exist a constant such that like that is bounded above 2n square and it is tight, okay? so yeah, that's all of the Asymptotic notation You might say that the big o notation of big o and little are similar But the main difference is that the bound holds for some constant c but in the little bound The boundary is holds for all constants so in so this is similar to big o notation But so the main difference is that f of n We say f of n as big o of g of n times g of n right this bound This bound is true for some c c greater than zero but for For little o we say it's bounded for all c. It's a little o of g of n this is Bounded f of n is less than the constant c times g of n For all constant c greater than zero in little o notation f of n becomes insignificant relative to g of n as it approaches infinity Excuse me, but yeah, that's basically it. We can talk about the rate of growth for each function All right guys, so if we look at this picture here This picture shows every single big o notation of every single running time of a function of big o of f of n So if you look at this notation We see that n factorial is the worst and the reason why is it because it the it grows very quickly Like the time it takes like the rate of change the time For the time for the values grows way faster in terms of time compared to the other Functions so like this time grows way too of way faster compared to O of c of n o of c to the end Okay, so o of c to the n means in exponential function, right? So like o of 2 to the n or 3 to the n right finding like like brute-force algorithms that that uses a lot of Time complexity right it uses it grows as if algorithm grows really fast and Let's look at this this this graph o of c of o of n to the c Okay, this is a con a polynomial a polynomial graph So o of n to the c is like o of n square and third and fourth and those values are like Using like a certain number of loops O of n squares like using two for loops if you like Traverse all the way through both of them. That's like o of n squared o of n cube might be like use three four loops O of n fourth stuff like that like exponential not exponential polynomial polynomial time o of n to the c Then here we have o of n log n and that's like that's like the time complexity of quicksort sorting algorithms Good sorting algorithms o of n. This is a good time complexity of it uses the It's a linear. It's like one one pass takes through is a good time complexity Uses one for loops of very efficient as it approaches larger and larger then we have o of log n, which is Also very good very good It's better than o of n because like it doesn't the time it takes does not approach that The time it takes doesn't approach that much when it goes to infinity and then we have constant o of one And that's that's the best because it only takes Takes like I don't know Takes very constant time so like that means when we say constant time it means like it runs like five seconds six seconds Seven seconds like no matter how much the input size is it will still run five or six seconds, right? Five seconds six seconds, and there there's some algorithms are like that right like where if you just turn it on It just automatically is on right like algorithms are constant. It just uses a certain number of space. So yeah, that's this That's all the the graphs of the time complexities Of o of n and I explain all the time complexities. I hope you guys enjoyed this video great. Come subscribe. I'll check you guys later


Why are these men rocking a Saturn V with their feet? I'm Amy Scheer title and this week on Vintage Space we're talking about the Saturn 500F Shake Test. Building a rocket to go to the moon is a little more involved than just building a rocket and launching it to the moon. In the case of the Saturn V every piece of the rocket was built by a contractor in a different location and it was up to NASA to assemble the vehicle at the Kennedy Space Flight Center. That meant technicians at the Cape also needed the facilities to lift up the rocket stages to mate them, check out that they were all talking to each other and then move the finished rocket from the vehicle assembly building onto the launch pad with the crawler way. Checking that all this pre-launch hardware was working demanded a separate round of tests and for this NASA didn't use a flight-ready vehicle. The agency used a dummy Saturn V, in this case of the Saturn 500F for facilities integration tests. It was used to make sure that it fit the service platforms that worked with the crawler transporter to get between the VAB and the launch pad and that all the connections to the mobile launcher and support equipment worked. Midway during its active lifetime at the Cape in 1966 Hurricane Alma swept through and the vehicle was hastily moved from the launch pad back into the VAB for shelter. Perhaps inspired by this brush with a hurricane because Florida can get some pretty nasty winds engineers decided to run a very simple shake test with the rocket. Technicians on the bottom pushed with their legs while men on top pulled with a rope attached to the spacecraft. Shaking the mammoth rocket in an attempt to get it to reveal its natural frequency. Something that would in turn give engineers an indication of its structural mechanics. The manual shake test actually knocked the launch escape system right off the top of the rocket. But luckily it didn't land on anybody when it fell. In an era before computer modeling was common enough to solve all the problems technicians came up with some pretty interesting workarounds, eh? Leave your questions and comments below and for more on the Saturn 500F shake test check out the latest article on vintage space over at Popular Science. You can grab me on Twitter for daily old timey space content as AST Vintage Space and for weekly vintage space video updates don't forget to subscribe.


So, what up everybody, I'm Joe for jaspyscasebrake.com. We did it, big thanks everybody who knocked out all these brakes, plus the related fillers right here, because that knocks out tonight's brake credit promo. It was tonight only, and we all made it happen with plenty of time to spare, so thanks everybody. Top three will win brake credit. Spots two and three will win $125 of brake credit each. Grand prize, name on top, $750 of brake credit, it's pretty nice. All we have to do is fill these brakes. Chronicles draft picks, check, and obviously this is always in the brake schedule and the next tab over so you can always keep track of it throughout the evening. The hit parade brake, plus any fillers. There's the hit parade, there's the hit parade people, and the filler was that blaster box. Done and done. Pristine baseball picker team three, there's the list right there. Chronicles soccer, we knocked that out too. There's a Chronicles soccer using the original 20 names, original 20 names right there. Then the Chronicles football, plus the filler. There's the filler for the Chronicles football, and there's the Chronicles football NFL edition picker team number four. So that's a total of 210 names. So let's gather all of your names, new dice, new list, and fingers crossed ladies and gentlemen, thank you very much. It's going to be the top three winning some of that delicious, delicious brake credit. Brake credit. Yeah, green, the color of money, I love it. Top three after 11, fingers crossed. Top three after 11, five into six, one, two, three, four, five, six, seven, eight, nine, ten, and 11th and final time. After 11, big drum roll, drum roll, drum roll, drum roll, drum roll, drum roll. Thanks everybody for getting involved. Listen, this is just a little bonus for doing what you would normally do, join our group brakes on jaspyscasebrakes.com, so I appreciate it. Hopefully a little bonus for a few of you.  Chris Butler, only the top three can win brake credit. Chris Butler in spot four, that's the worst spot, Chris, but thank you. Thank you for trying tonight, I appreciate it. Happy times for the next two. You got $125 of brake credit each, Jeremy Hove and Chad B, congrats. The grand prize will go to the name on top, Patrick Garrison, congrats to you, congrats to the top three, but Patrick, $750 of brake credit going your way. I'm going to email that to you, whatever email you've been using for your orders, I'm going to email it to that email, check your spam folder if you don't see it, it'll arrive to you as like a gift card, $750, you don't have to use all of it at once, it'll save the balance for you, et cetera, et cetera, et cetera. Congrats to Chad and Jeremy as well, $125 of brake credit going your way, check your emails. Thanks for watching, thanks for breaking with us everybody, appreciate it. I'm Joe, I'll see you next time for the next promo, bye-bye.


Paul Pelosi's attack. Paul Pelosi, husband of the White House speaker Nancy Pelosi, was attacked and briefly taken captive in his own home on Friday by David DePaype. According to an FBI affidavit, the attacker asked Pelosi, where is Nancy, who was not home at the time of the attack? DePaype then stated he was going to hold Nancy hostage and talk to her. If Nancy were to tell DePaype the truth, he would let her go. And if she lied, he was going to break her kneecaps. According to a press release from Nancy Pelosi's office, Paul Pelosi underwent successful surgery to repair a skull fracture and serious injuries to his right arm and hands following the attack. San Francisco District Attorney Brooke Jenkins said that the attacks appear to be politically motivated. DePaype stated to police that he was on a self-claimed suicide mission, also targeting other prominent politicians. He is now facing federal charges of assault and attempted kidnapping along with state charges of attempted murder and assault with a deadly weapon.


And welcome to the 2pm update with David White here. We got a few things going on, why the market's going sideways. Earnings on AMAT came out last night. It was up to a high of $107.59 earlier, printing off at about $105 today. They weren't that good. We had a little bit of a squeeze, not much of one, to get folks out. But on the whole, basically flat on the day so far. We've talked on and off my show a few times about Carvana and their impending doom, at least in my opinion, laying off some more folks as they get ready, I suspect, to find out that they will eventually be on the ash heap of history. Nvidia, which is down a little bit today, I finally saw some numbers that are in the range of knowing how their video cards are selling. And actually fairly good, 150,000 of their top of the line 4090s. These sell for their own card for about $1,500. Partner cards who buy the chips and then sell the cards themselves can range anywhere from $2,100 to $2,500. There are some out there that sell around the same $1,500 range. But a lot of people squawking, but it doesn't look like there's a real problem with people actually buying them. I think Nvidia figured out during the pandemic when the scalpers were getting $500 to $1,000 that if you do make the Cadillac, I don't know if that even fits anymore, if you do make the top of the line product, there are people willing to pay up severely on it. And probably from the massive discussion in the den today about paying up for tickets for a singer, they pay up a lot of stuff.


Hey everybody, this is Brian and welcome to the 10th Python tutorial. Man, we are just hauling through these, collect Python 10. And what I want to cover today is exemption handling or error handling. Obviously, you've seen me make a few mistakes and I'm sure as you've been following along you've made a few mistakes. So how do you handle those mistakes?   And what does that really mean?  So we're just going to say def do something and let's say we're going to n equals 0, x equals 5, y equal, let's just get creative here, x divided by n, print the value of y. You know, just something generic here. And then we're going to totally forgot our little brackets that always bites me for some reason. Just so we can see that we're starting the program and then we're going to do something. And let's run this and see what happens here. Oh no, we have an error. Shocker, we're dividing by 0. Well, this is a standard error message in Python and I'm sure you've seen these before. And this is called the trace back. And what it does is it starts where the error originated. So like if we just go line numbers, line 13 in module, which means in the current module, if it was a different module, it would give you this module name would be different. All right, so line 13 do something. So we know instantly it's coming from do something. But it goes a step further and says line 9 in do something. And it gives you the actual code that's calling the error line 9, this guy right here.  If you've taken any sort of rudimentary math class, you know, you cannot divide by zero. I'm horrible with math and even I know you can't divide by zero. It's just not possible. You can't do it. All right, so how do we get around this? Like let's actually say number and let's give the user the ability to enter the number. Right, so we're going to run this. What do we do again? Oh, yeah, dirt. All right, so we get 1.1. We can change this. So we know our function is actually working, 2.5. So we're going to take whatever divided by whatever. Now if the user enters zero or back to square one, we're going to have that same error again. We don't want that. So we need some sort of exemption handling and it's in the form of a try exempt finally. And we're going to explain that. Say try and we're going to indent this code. Notice how it gives you a little squiggly when you use a try. It's expecting an exempt or a finally. The first thing we're going to do is exempt or accept, sorry. And we're just going to accept exemption as E. And this is what's called a catch all. Let's make that a little prettier. Something went boom. Now what try and accept does is it'll try this code.  This will catch any exception out there. So let's run this. And you see now it says something went boom, division by zero. So we have a nice pretty, you know, something happened. And E is actually an object. So you can actually get into the args, you can do the trace back, you can do pretty much whatever you want. You can get the actual base memory on that. So it makes it a lot easier to work with. And notice how it didn't kill your program. Even though there was an error, your program keeps juggling along happily because you encapsulated it within a try and accept. So that's one way of doing that. Now a finally is a little bit different. Finally will always execute regardless of what happens up here. Notice how why never prints because we had a division by zero error. But if we run this, you'll see finally I get to run. So even though there was an error, finally will run. And you don't necessarily need this code. You can just do a finally. You can do try finally. You would do this for the example if you had a file or database or some resource. You would open it and then when you're done in the finally block, you would actually close that resource regardless of whether or not you had an error. Now as you might have guessed, if you're with, you know, been working with other languages, you can actually classify exemptions. So we'll say zero division error. We'll say we please do not divide by zero. Let's get rid of that. Now when we run this, notice how it says please do not div by zero instead of the catch all because we've actually specified we want to catch zero division errors and do this block. General rule of thumb catch all are bad. You want to know what sort of problems are rising in your application. Another thing you should never do is simply pass. For example, runtime error and we'll just say pass. If we've never covered pass before, what pass does is it just does nothing. It just takes the execution context and jumps right out. That'll create what's called a silent error. Actually it'd be a better example if I had just done it in the division by zero. Let's throw a pass in there. That's what some people do. They'll say if you divide by zero, just pass. That creates what's called a silent error. You never knew that happened. You never, never, never, never want to do that. Repeat after me, never do that. Reason why is because you want to know that error occurred. You want to do something with that error. You want to either log it or correct the problem. You know, for example, please do not div by zero. You're telling the user, hey, choose a value greater than zero. One thing you should really understand about error handling is that you don't want to go completely crazy. As you can see, the error handling actually is bigger than the algorithm that we wrote. That's called defensive programming and it's good to do that. But you don't want to make an exemption for every single type of runtime error that's possible and there's a lot of them. So if we go out here, I was wondering what was that? Ow. Stocks, never mind.  And you don't want to make one for each and every one of these. For example, you don't want an OS error in that algorithm we just wrote because we're not dealing with the operating system. You don't want a stop iteration error because we're not dealing with it. So you kind of got to look at your code and say, what really is going to happen here? Well, division by zero is completely possible. But I would always, as a rule of thumb, put the catch all in here because if you don't and something else happens, you're going to get a runtime error. For example, let's do this. Let's just comment this out. And let's actually do, let's say we just expect a runtime error. And we're going to say print. This may not be the best example. Actually, it's not. Let's do OS error. There we go. Now let's run this. You can see how now our program crashes because we never captured that division by zero, either this way or with our catch all. So you're going to want, at a bare minimum, a catch all statement. Something went boom, division by zero. But it's always better to know what kind of errors you're getting into. That way you can handle them appropriately. That was a mouthful. It's been a long day. Thank you for watching. Please feel free to visit my website for the source code for this and other tutorials. Just go to Python and I'll upload. I just did a bunch of videos. I think I did like four or five videos right in a row. So I'll upload all those before I go to bed tonight. Hey kitty, daddy's recording. Yes, I know. You're hungry. Visit Facebook and join the Void Realms Facebook group. There's 200 of us out there that are eager to help. And if you do join, be sure to offer help whenever you can. Nobody's an expert in any one thing, but if you have information and somebody's asking for help, just jump in there and leave a quick comment.