﻿1
00:00:00,410 --> 00:00:05,180
‫So our next big topic is different terms for inputs.

2
00:00:05,180 --> 00:00:11,870
‫And to explain this, I'm going to start with something that we've already looked at and that is a four

3
00:00:11,870 --> 00:00:15,290
‫loop that is followed by another for loop.

4
00:00:15,290 --> 00:00:19,460
‫And each of the four loops are running in times.

5
00:00:19,760 --> 00:00:27,050
‫And we said that would be O of two N and then we drop the constant and it becomes o of N.

6
00:00:27,350 --> 00:00:30,950
‫So now I'm going to make a couple of changes to this function.

7
00:00:30,950 --> 00:00:39,290
‫Instead of just passing this one variable in, I'm going to pass it to variables that I call A and B,

8
00:00:39,590 --> 00:00:48,470
‫and then we'll have the first for loop run a times and the second for loop will run B times.

9
00:00:48,740 --> 00:00:55,310
‫So the difference here being that we have two different terms, A and B that we're working with.

10
00:00:55,730 --> 00:01:00,950
‫So the mistake that people will make is they'll look at the first for loop and they'll say for loops

11
00:01:00,950 --> 00:01:08,300
‫are O of NW and then they'll look at the second for loop and say, well, that must be O of N as well.

12
00:01:08,510 --> 00:01:12,050
‫And then they add them together and that becomes o of to win.

13
00:01:12,050 --> 00:01:20,600
‫And then they drop the constant and say that it's o of n, but you can't do this with this function.

14
00:01:20,780 --> 00:01:30,140
‫Now, if you think about this as just an algebra problem, you can't say that A equals N and B equals

15
00:01:30,140 --> 00:01:30,650
‫N.

16
00:01:30,980 --> 00:01:34,070
‫These are different terms.

17
00:01:34,340 --> 00:01:41,390
‫So you need to say that the first for loop is O of A and the second for loop is O of B.

18
00:01:41,390 --> 00:01:51,410
‫And when you add these together, this is as far as you can simplify this O of a plus B Likewise, if

19
00:01:51,410 --> 00:02:00,320
‫you have a for loop inside of A for loop, you would say that this is O of a times B, so you have to

20
00:02:00,320 --> 00:02:03,170
‫show these variables separately.

21
00:02:03,710 --> 00:02:07,790
‫You have to show different terms for inputs.

