﻿1
00:00:00,350 --> 00:00:04,190
‫So now we're going to look at O of n squared.

2
00:00:04,340 --> 00:00:11,090
‫So I'm going to bring this back from the last video where we had one for loop after another.

3
00:00:11,210 --> 00:00:18,020
‫Except what I'm going to do is I'm going to change this where we have one for loop inside of another.

4
00:00:18,020 --> 00:00:22,790
‫And when we do this, we're going to get a very different outcome.

5
00:00:22,910 --> 00:00:27,530
‫So now let's flip over to VS code and take a look at this.

6
00:00:27,890 --> 00:00:36,230
‫So there is our new function there with our nested for loops and we will run this with the number ten.

7
00:00:37,100 --> 00:00:38,420
‫So over with our output.

8
00:00:38,420 --> 00:00:46,010
‫I'm going to scroll to the top and you can see that this starts with zero zero and then it will go all

9
00:00:46,010 --> 00:00:49,850
‫the way through to the bottom to nine nine.

10
00:00:50,120 --> 00:00:57,260
‫So we pass this function, the number ten, and it printed out 100 lines.

11
00:00:57,380 --> 00:00:59,840
‫So now let's flip back.

12
00:01:00,080 --> 00:01:09,590
‫So this ran n times n times or n squared, and that is where we get o of n squared.

13
00:01:09,740 --> 00:01:17,900
‫So now let's take a look at o of n squared on our graph and you can see that o of n squared grows much

14
00:01:17,900 --> 00:01:23,750
‫faster than o of n, which is to say it is a lot less efficient than o of n.

15
00:01:24,050 --> 00:01:31,220
‫So if you have two different ways that you could write a particular function and one way is O of n squared

16
00:01:31,220 --> 00:01:38,550
‫and the other way is O of n, that would mean that o of n is going to be the far better way to write

17
00:01:38,550 --> 00:01:39,540
‫that function.

18
00:01:39,840 --> 00:01:46,170
‫And o of n squared will be the least efficient big o that we will see in this course.

19
00:01:46,440 --> 00:01:48,540
‫And that is our overview.

20
00:01:49,090 --> 00:01:50,830
‫Of O of n squared.

