00:01
So for this problem, we're just going to call this procedure ternary.
00:07
And ternary takes in a list of integers, so some n number of integers.
00:19
And there's at least going to need to be minimum of one of them.
00:25
All right.
00:25
And then we also have the search algorithm, the item we're searching for, which is also an okay, so first we want to define our search interval.
00:50
So we'll set i equal to 1 and j equal to n.
00:59
So i is going to be the position of the first element of our search interval and j will be the last element of our search interval.
01:09
So at the moment we've just initialized it to the entire list.
01:16
Okay, and so then we'll consider the case for while i is less than j minus one okay and so this ensures that the algorithm would stop when there's at most two elements in the search interval we also want to define a couple of new variables okay so lots of definitions here so let's let l lowercase l be equal to the floor of i plus j divided by three okay and we're going to do essentially the same thing with you okay so it's going to be the floor except it's going to be two times i plus j divided by three and so these are also setting positions in our list okay so then we can determine in which sub interval x lies right so if we think about all these variables if we have a list of so a1, all the way up to a .l.
03:02
It's going to go all the way up to au, and then up to a subj, right? so we're just sort of creating roughly evenly distributed intervals here...