﻿1
00:00:00,510 --> 00:00:00,610
‫Okay.

2
00:00:00,730 --> 00:00:03,730
‫This is going to be our introduction to QuickSort.

3
00:00:03,730 --> 00:00:06,580
‫So I'm going to bring up an array here like this step.

4
00:00:06,580 --> 00:00:08,830
‫I'm going to show it like this.

5
00:00:09,370 --> 00:00:14,530
‫And the way QuickSort works is we're going to have a pivot point and we're going to make that first

6
00:00:14,530 --> 00:00:22,810
‫item that for the pivot point, and we're just going to compare every item in the array to that number.

7
00:00:22,810 --> 00:00:23,920
‫So we'll start at the six.

8
00:00:23,920 --> 00:00:24,790
‫That one's greater.

9
00:00:24,790 --> 00:00:27,970
‫I'm going to color that grey because it's greater than.

10
00:00:28,900 --> 00:00:31,150
‫And the one is less than.

11
00:00:31,690 --> 00:00:39,070
‫So if we find an item that is less than, we're going to exchange it with the first item that is greater

12
00:00:39,610 --> 00:00:40,510
‫like this.

13
00:00:41,730 --> 00:00:43,740
‫Then we move to the next one that's greater.

14
00:00:44,190 --> 00:00:49,110
‫This one's less than we exchange it with that first greater than item.

15
00:00:50,020 --> 00:00:52,810
‫And we do this again, an exchange that.

16
00:00:53,560 --> 00:00:55,810
‫And then the five is greater than four.

17
00:00:55,810 --> 00:00:57,790
‫So we'll color that one in gray.

18
00:00:58,940 --> 00:01:00,730
‫And we have one step left.

19
00:01:00,740 --> 00:01:07,400
‫We're going to swap that for with that last item that is less than like this.

20
00:01:07,910 --> 00:01:14,150
‫And now the four is sorted, so I'll colour it green because that's going to be where it is after we

21
00:01:14,150 --> 00:01:18,950
‫sort everything and everything that's less than the four is on the left.

22
00:01:19,040 --> 00:01:23,000
‫Everything that's greater than the four is on the right.

23
00:01:24,240 --> 00:01:32,010
‫So now what we're going to do is run quicksort again on just this section of the array, and we're going

24
00:01:32,010 --> 00:01:33,670
‫to do it on the other side as well.

25
00:01:33,690 --> 00:01:36,690
‫So let's focus on the left side first.

26
00:01:37,470 --> 00:01:40,260
‫The two is going to be our pivot point now.

27
00:01:41,190 --> 00:01:43,350
‫We'll compare the one to the two.

28
00:01:43,350 --> 00:01:45,930
‫It's less and the three is greater than.

29
00:01:46,560 --> 00:01:51,990
‫And now we're going to exchange the one and the two, and now the two is sorted.

30
00:01:53,090 --> 00:01:57,620
‫And then we'll run this recursively on these two.

31
00:01:58,040 --> 00:02:02,870
‫And because there's only one item in each of these, we know that those are in the correct spot.

32
00:02:03,660 --> 00:02:05,670
‫And I'll mark those as sorted.

33
00:02:05,700 --> 00:02:09,570
‫On the other side, we're going to have the six be the pivot point.

34
00:02:10,020 --> 00:02:12,570
‫Seven is greater, five is less.

35
00:02:12,570 --> 00:02:14,610
‫So we'll exchange these two.

36
00:02:15,500 --> 00:02:18,380
‫And then we'll exchange the six with the five.

37
00:02:19,010 --> 00:02:25,010
‫So the six is sorted and now the five and seven are sorted as well.

38
00:02:26,410 --> 00:02:30,880
‫And that's our overview of the workings of QuickSort.

