﻿1
00:00:00,480 --> 00:00:06,720
‫So now we're going to talk about a helper function that we're going to build that will use in our merge

2
00:00:06,720 --> 00:00:07,500
‫sort function.

3
00:00:07,500 --> 00:00:10,410
‫And that helper function is called merge.

4
00:00:10,710 --> 00:00:15,420
‫So we'll have a function called merge and one called merge sort.

5
00:00:15,750 --> 00:00:19,550
‫And I'm going to have two different intro videos on Merge.

6
00:00:19,560 --> 00:00:25,080
‫I'm going to talk about it very high level in this video and then we'll take it a level deeper and the

7
00:00:25,080 --> 00:00:26,040
‫next video.

8
00:00:26,520 --> 00:00:33,000
‫So Merge is going to be the function that takes two sorted arrays and remember these both have to be

9
00:00:33,000 --> 00:00:38,250
‫sorted and it combines them into one sorted array.

10
00:00:38,790 --> 00:00:43,170
‫So let's put this back and look at a high level how this works.

11
00:00:43,530 --> 00:00:51,270
‫We're going to have two variables AI, which iterates through the first array and J, which iterates

12
00:00:51,270 --> 00:00:52,800
‫through the second array.

13
00:00:53,160 --> 00:01:01,410
‫And what we're going to do is compare I and J and the one that has the lowest value we're going to copy

14
00:01:01,410 --> 00:01:06,900
‫into a separate array, and then we're going to do it again.

15
00:01:06,900 --> 00:01:09,780
‫And in this case, J is less than.

16
00:01:10,230 --> 00:01:15,240
‫And we keep doing this until one of the arrays is empty.

17
00:01:15,780 --> 00:01:20,100
‫So now that that second array is empty, it breaks us out of our loop.

18
00:01:20,250 --> 00:01:24,900
‫And that will create a separate loop that loops through these remaining items.

19
00:01:25,230 --> 00:01:28,740
‫And we'll talk about this in a little more depth in the next video.

20
00:01:28,740 --> 00:01:32,160
‫But this is our first introduction to merge.

