An Entire Computer Science Degree in 12 Minutes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i'm going to show you an entire computer science degree in 12 minutes we're going to learn everything from the basics to how to hack twitter let's go code is just instructions that execute line by line functions are just self-contained reusable chunks of code a function is recursive if it calls itself trees are data structures for storing numbers if we had five at the top everything to the left would have to be smaller than it so this could be zero everything to the right would have to be bigger than it this is true for every single node variables can store some data in them and that data can change as you can see here aka their variable conditionals will check variables and run different code depending on what the value of those variables is loops check some condition and they keep repeating until that condition is met structures logically store some information together to make it easier to access for example person has a name and has an age arrays are essentially just lists of variables we can overwrite any one of these values and they sit next to each other in storage when you're programming every time a function is called it creates what's called a stack frame with this function if we called it with i equals 10 this is what our stack frame would look like we start off with a stack with i equals 10 but then we were cursed on ourselves as you can see here with i equals nine and then we know from this stack frame we're gonna have to return to the one before it this will go all the way down until i equals one and then these stack frames will start popping off as the code is returning to the previous stack frame all of this is stuff that you don't have to manage yourself this is just done for you automatically this is just how it's stored in memory now this is interesting if you forgot your base case and you continued to recurse on yourself infinitely you would run out of stack memory so you only have so much memory allocated to stack and if you created so many stack frames that you accidentally ran out of stock memory this is called stack overflow it's all making sense now doesn't it sometimes when the stack pops we want the memory to stay around so there's this thing called keep memory in c the way you're going to allocate on the heap is using the malik keyword but if you've ever used c plus plus or java the way you do it is with the new keyword if something is allocated on the heap you are returned a pointer to that value which just looks like an address what's really cool is that pointers are actually the exact same thing as arrays because a pointer points to an address and an array points to the first element of a list as an address this is how we will create an array of size four on the heap however what malek is actually going to return to us is actually just this address so if we wanted to access the second element of the array we could literally just take the array and plus one that would give us this address if statements in some pretty cool ways if you had a and b which are both boolean so they either are true or they're false and you had an if statement that was if not a or not b this is actually the exact same thing as if not a and b programmers do everything from the terminal it's the scary looking black box you see whenever somebody's hacking in one of the movies this is actually your best friend and you're gonna run most of your code from this it's not scary please get comfortable with it all of the commands that you use to run in this terminal are called bash commands so ls for example will list all of the folders and files in this current directory as you can see i clearly made a mistake naming this file commands can have additional arguments to them that are defined so for example ls has a dash a option which is going to show me all the files and folders including the hidden ones as you can see we've got a bunch of random folders here c plus is just c but with classes and objects as you can see in front of me now something really cool about the name c plus plus actually means c equals c plus one in the c programming language so c plus plus is just a way of them saying it's c but it's one better than c now something even more interesting is that c sharp is just c plus plus plus plus so it's c plus two i don't know i thought it was cool it's impossible to measure algorithms with time because every computer has a different chip it has a different setting that has a different speed so the way we measure algorithm speed is with number of steps in fact we don't even care about the number of actual steps we just care about how many steps in relation to the input size this is called big o of n notation there are a few really interesting data structures the first would be a queue a queue adds things to the back and it takes them from the front much like a queue at a grocery store or a coffee shop a stack adds to the top and takes from the top a good example of a stack would be a stack of books put one on top and then you take off the top also trees we already went over linked lists basically store some data and then a pointer to the next data some data pointer to the next data and then know if it's the end of the list now all computers run on transistors transistors run off of a sequence of ones and zeros which make up instructions machine code are instructions that run on the transistors it's built from assembly assembly are basically these instructions but in english and the assembly is created from our friend c we come full circle on a computer all numbers are represented as binary ones and zeros now if we need to represent a negative number you might be saying well couldn't we just add a one or zero to right here one would represent negative and zero would represent positive the problem with that that would give us two representations of the number zero so they've invented this thing called two's complement which essentially is a way of storing numbers that are positive and negative in binary that doesn't have this property i'll let you google that on your own let's say you're on a mountain range right here and you want to get to the tallest mountain in that mountain range now you really can't see too far because it's very foggy a greedy algorithm tells you to take the local optimal it just says don't go down only go up because you'll be higher than you were before so with a greedy algorithm you would make it here and that's pretty tall but that's not actually the tallest point divide and conquer algorithms take a complex problem and break it into an easier problem operating systems have these things called kernels kernel basically manages the system every time you said new or every time you opened a file you were actually just asking the kernel to do it for you remember back when we told you code runs line by line well that's still true this sequential running is called a thread of execution now what we didn't tell you is that you can have multiple threads of execution running at the same time now in the last month this channel has gone from 3 000 subscribers to 40 000 subscribers if we can get to a hundred thousand in the next 30 days i will shave my head as a reward now let's talk about my favorite thing hacking generally comes when you let the user input something in this case twitter might have a text box for tweeting most people would say hello world if i knew that they were storing my tweet in an array that was allocated on the stack i could actually take advantage of that this is the stack frame for the function that's writing my tweet now let's say that they said this tweet was allocated on the stack and it can be of length one two three four if i make a tweet that has more than four characters in it which i'm obviously going to do i could keep going and eventually overrun the return address now what's really interesting is if i put malicious code right up here then all i have to do is write the rest of the array with the return address being where that malicious code is so when this stack frame is ready to pop off it will return to my code this is called a buffer overflow machine learning relies heavily on neural networks neural networks are set up to act kind of like the human brain each individual node is called a neuron it takes some input and it either produces a one or it produces a zero we have multiple layers of neurons and then we have this thing called an output layer as you can see the output is either a circle triangle or a square now the output is going to look something like 0.5 maybe 0.2 0.3 what this is saying is it's a 50 probability that it's a circle now these are called the hidden layers these are the layers that do most of the computation and then this is called the input layer and what this does is it cuts this image up into pixels and then each of these input nodes basically just represents the pixel data at each of those pixels now what's cool about these is that every single node is connected to every other node in the layer above it each of these connections has what's called a weight now what is the weight it's actually just completely random at the beginning now let's zoom in for a second each node is connected to the nodes in front of it the input for any given node is the weight multiplied by the output so if this outputs a one and this outputs a zero the input for this node is going to be one times w1 plus 0 times w2 each of these nodes takes whatever their input is let's say the input is 0.3 and it decides if it wants to output a one or a zero so basically every single node only outputs a one or a zero it's very simple the real magic are these weights now remember i told you there's an output probability about which shape is right so let's say we passed in an image of a circle and it ended up telling us that it's a 90 probability it's a square well because this is training data we know that that's wrong so what we do is we go back through all the layers of nodes we adjust all of their weights to represent something that will actually give us the right answer and then we keep doing that on repeat until we get all of the weights just right and that's what a neural network is one of the lesser known but very cool things in programming is called a co-routine now what co-routines allow you to do is this thing called a yield return which will let you return but more just pause the function where it is for example in a regular function if we did a return this code would be completely inaccessible because every single time we called this function it would set x to zero and then it would return x but with a co routine we pause execution when we yield return and then when we call it again it just continues on now that might sound kind of useless but it actually has a really good use case imagine we wanted to write a function that returned every single node in a binary tree what we could do is write a function that would return the first node and then when we called it again it would have to remember that it's already returned the first node and then it would return the second node and then the next time we call it it would have to remember it returned the first node and returned the second node and it would have to return the third node but with co routines you can have a function that returns the first node and then yield returns and then when you call it again it just calls the next node and when you call it again it calls the next node it's really really useful for enumerators obviously that process is called enumerating now if you didn't understand most of that don't worry please you're not supposed to do not feel bad this is meant to give you the first one of these topics when you go to learn a new topic if you already have any basic familiarity with it it makes it much easier to learn this is just giving you that little bit that might help you when you're finally learning it watch this video again and write down all the topics you don't know and then go through them one by one and research them alright go break some eggs [Music]
Info
Channel: Jason Goodison
Views: 540,905
Rating: undefined out of 5
Keywords: Jason Goodison, Devon Crawford, How to learn programming, How to learn computer science, University, Computer Science, tech with Tim, nick white, joma tech, Java programming, computer science degree, 10 years of coding, C Programming, assembly, stack, program counter, programming, Coding interviews, computer science major, my computer science degree, how to learn programming, computer science, cs degree, computer science degree in 8 minutes, computer science for beginners
Id: EJiVWoFk8GA
Channel Id: undefined
Length: 12min 34sec (754 seconds)
Published: Sat Aug 06 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.