What would you say if I asked you what is the bago of the function, Finding Nemo?
Well, to make this a little bit cleaner, let's just remove performance done now because we've learned
that it's not very, very important and we can remove the consoles as well.
And looking at this and the Sloup, what would you say the Bago is?
In this video, we're going to learn about our very first big notation, as we said, a runtime is simply
how long something takes to run.
How does this function?
And it's runtime grow as our input increases, as our input goes from just a single item in an array
nimo to 10 items in array to one hundred thousand, how does the efficiency of this function increase?
If we look at this graph and we say we have four items in the array, while the number of operations
is going to be.
For right, because we're going to loop through each item and say, is this animal, is this animal,
is this animal, is this animal four times no matter what, we're looping four times at least with the
way that we have this code set up.
If we have five items in the array.
It's going to be five operations, five loops.
Six is the same.
Six items is six operations, seven is seven operations and eight is eight operations.
Do we see a little bit of a pattern here?
Well, we can draw a line through it.
This is linnear, right, as our number of inputs increase, the number of operations increased as well.
And here, ladies and gentlemen, we've learned our very first bigo notation.
We say that the Finding Nemo function.
Has a big notation of O.
Hmm, that's a little bit strange.
This is just a notation that you have to get used to, but we say Bigo of NP or what we call linear
linear time.
It takes linear time to find nimo.
Now, where does this end come from?
This end can be anything really I could put X, I could put fish in here if I want is just an arbitrary
letter and we usually give and when it comes to Bigo, this is just a standard that you'll see across
the board.
And simply means the big O depends on the number of inputs, the number of fish.
So if we just had the NIMO array, this would just be.
One, if we had the everyone array, this would be 10 and we had the larger be one hundred thousand.
But as the inputs increase, you see that the number of operations increase linearly with it.
Oh, when is probably the most common big rotation you'll find if we go back to the graph, you can
see that Owen is right here in the yellow region that says fair as the number of elements increase.
You see, that is just a straight line.
The number of operations increases by the same amount.
Because keep this in mind, Bigo doesn't measure things in seconds.
Instead, we're focusing on how quickly our runtime grows.
We simply do this by using the size of the input which we call and or anything else that we want really
and compare to the number of operations that increase.
That's what scalability means as things grow larger and larger.
Does it scale?
So the Find Nemo function is, oh, of ln linear time, another way to think about it is this.
If we had a compression algorithm, let's say this function is this little compression and the input
is this little box, what's the big notation of this function?
Well, if we had one element, it will just compress.
One item, if we had multiple elements, again, we still have to run each box through the compression
algorithm to compress the box.
If we look at the function for the compress boxes, well, we're using the five and ESX syntax here,
but we're essentially looping through each box and in our case, we're just slogging it.
But you can see here that all of these all we're doing as the input increases, the boxes, the number
of boxes increases, the number of operations increase, and that is on linear time.
Congratulations, you just learned your first Bigo notation, and this is probably the most common,
but there's a few others.
So what other big annotations do we have other than linear time?
For that, you're going to have to keep watching, I'll see in the next video, bye bye.