1
00:00:00,890 --> 00:00:07,130
What would you say if I asked you what is the bago of the function, Finding Nemo?

2
00:00:07,910 --> 00:00:13,790
Well, to make this a little bit cleaner, let's just remove performance done now because we've learned

3
00:00:13,790 --> 00:00:18,770
that it's not very, very important and we can remove the consoles as well.

4
00:00:20,320 --> 00:00:24,490
And looking at this and the Sloup, what would you say the Bago is?

5
00:00:26,230 --> 00:00:32,650
In this video, we're going to learn about our very first big notation, as we said, a runtime is simply

6
00:00:32,650 --> 00:00:34,360
how long something takes to run.

7
00:00:34,630 --> 00:00:37,090
How does this function?

8
00:00:38,110 --> 00:00:45,130
And it's runtime grow as our input increases, as our input goes from just a single item in an array

9
00:00:45,160 --> 00:00:52,180
nimo to 10 items in array to one hundred thousand, how does the efficiency of this function increase?

10
00:00:53,860 --> 00:01:00,220
If we look at this graph and we say we have four items in the array, while the number of operations

11
00:01:00,550 --> 00:01:01,600
is going to be.

12
00:01:02,490 --> 00:01:09,990
For right, because we're going to loop through each item and say, is this animal, is this animal,

13
00:01:10,410 --> 00:01:17,010
is this animal, is this animal four times no matter what, we're looping four times at least with the

14
00:01:17,010 --> 00:01:18,570
way that we have this code set up.

15
00:01:18,960 --> 00:01:21,780
If we have five items in the array.

16
00:01:22,200 --> 00:01:25,260
It's going to be five operations, five loops.

17
00:01:25,830 --> 00:01:27,300
Six is the same.

18
00:01:27,450 --> 00:01:34,740
Six items is six operations, seven is seven operations and eight is eight operations.

19
00:01:35,730 --> 00:01:37,890
Do we see a little bit of a pattern here?

20
00:01:38,490 --> 00:01:40,260
Well, we can draw a line through it.

21
00:01:42,020 --> 00:01:51,350
This is linnear, right, as our number of inputs increase, the number of operations increased as well.

22
00:01:51,740 --> 00:01:57,410
And here, ladies and gentlemen, we've learned our very first bigo notation.

23
00:01:57,950 --> 00:02:00,560
We say that the Finding Nemo function.

24
00:02:02,040 --> 00:02:06,300
Has a big notation of O.

25
00:02:09,060 --> 00:02:11,380
Hmm, that's a little bit strange.

26
00:02:11,430 --> 00:02:20,670
This is just a notation that you have to get used to, but we say Bigo of NP or what we call linear

27
00:02:21,270 --> 00:02:22,040
linear time.

28
00:02:22,830 --> 00:02:26,220
It takes linear time to find nimo.

29
00:02:27,180 --> 00:02:29,810
Now, where does this end come from?

30
00:02:30,740 --> 00:02:39,500
This end can be anything really I could put X, I could put fish in here if I want is just an arbitrary

31
00:02:39,800 --> 00:02:47,330
letter and we usually give and when it comes to Bigo, this is just a standard that you'll see across

32
00:02:47,330 --> 00:02:47,750
the board.

33
00:02:48,710 --> 00:02:55,700
And simply means the big O depends on the number of inputs, the number of fish.

34
00:02:56,720 --> 00:03:01,760
So if we just had the NIMO array, this would just be.

35
00:03:02,800 --> 00:03:11,050
One, if we had the everyone array, this would be 10 and we had the larger be one hundred thousand.

36
00:03:12,310 --> 00:03:20,290
But as the inputs increase, you see that the number of operations increase linearly with it.

37
00:03:22,090 --> 00:03:29,520
Oh, when is probably the most common big rotation you'll find if we go back to the graph, you can

38
00:03:29,520 --> 00:03:37,350
see that Owen is right here in the yellow region that says fair as the number of elements increase.

39
00:03:37,950 --> 00:03:40,020
You see, that is just a straight line.

40
00:03:40,290 --> 00:03:44,070
The number of operations increases by the same amount.

41
00:03:45,140 --> 00:03:49,130
Because keep this in mind, Bigo doesn't measure things in seconds.

42
00:03:49,160 --> 00:03:53,540
Instead, we're focusing on how quickly our runtime grows.

43
00:03:54,080 --> 00:04:00,380
We simply do this by using the size of the input which we call and or anything else that we want really

44
00:04:00,830 --> 00:04:04,480
and compare to the number of operations that increase.

45
00:04:04,880 --> 00:04:08,940
That's what scalability means as things grow larger and larger.

46
00:04:09,110 --> 00:04:10,010
Does it scale?

47
00:04:11,310 --> 00:04:18,750
So the Find Nemo function is, oh, of ln linear time, another way to think about it is this.

48
00:04:19,500 --> 00:04:25,770
If we had a compression algorithm, let's say this function is this little compression and the input

49
00:04:25,770 --> 00:04:31,460
is this little box, what's the big notation of this function?

50
00:04:31,800 --> 00:04:35,580
Well, if we had one element, it will just compress.

51
00:04:38,520 --> 00:04:46,500
One item, if we had multiple elements, again, we still have to run each box through the compression

52
00:04:46,500 --> 00:04:48,840
algorithm to compress the box.

53
00:04:50,350 --> 00:04:58,270
If we look at the function for the compress boxes, well, we're using the five and ESX syntax here,

54
00:04:58,390 --> 00:05:03,990
but we're essentially looping through each box and in our case, we're just slogging it.

55
00:05:04,240 --> 00:05:11,860
But you can see here that all of these all we're doing as the input increases, the boxes, the number

56
00:05:11,860 --> 00:05:17,860
of boxes increases, the number of operations increase, and that is on linear time.

57
00:05:19,420 --> 00:05:25,560
Congratulations, you just learned your first Bigo notation, and this is probably the most common,

58
00:05:26,050 --> 00:05:27,400
but there's a few others.

59
00:05:28,150 --> 00:05:33,040
So what other big annotations do we have other than linear time?

60
00:05:34,050 --> 00:05:38,370
For that, you're going to have to keep watching, I'll see in the next video, bye bye.
