WEBVTT

00:00.410 --> 00:05.030
In the previous example, we calculated the complexity of the iterative method.

00:05.030 --> 00:07.250
So now let's do it with the recursive method.

00:07.250 --> 00:07.400
Here.

00:07.400 --> 00:14.030
Suppose we need to calculate the fraction of a certain number, for instance, six, which will produce

00:14.030 --> 00:14.900
here.

00:15.110 --> 00:21.530
Actually, let's make this here for example, we want to create something like that six fractional number

00:21.530 --> 00:27.890
six and which will produce the six fraction equals here.

00:28.820 --> 00:40.670
Six, multiply by five, multiply by four, multiply by three, two and one, which is equal to 27 720.

00:42.140 --> 00:44.570
So for this purpose we can use the recursive method.

00:44.570 --> 00:49.010
So which is we're going to write this in this lecture.

00:49.010 --> 00:54.560
So here let's actually create a new method named Integer Fractional.

00:56.270 --> 00:58.850
Or factorial, factorial.

00:58.970 --> 01:03.710
And here we this will get a new integer n here.

01:03.980 --> 01:06.230
And now if our.

01:07.370 --> 01:12.110
N is equal to one, then return one.

01:12.750 --> 01:14.580
Signs here.

01:16.850 --> 01:24.470
And, uh, else, if it's not uh, executed, then return and multiply by a fractional fraction.

01:25.630 --> 01:26.530
Factorial.

01:27.550 --> 01:28.780
N minus one.

01:29.440 --> 01:31.060
That's our function.

01:31.060 --> 01:37.750
So for the preceding function, we can calculate the complexity of this similarly to how we did in iterative

01:37.750 --> 01:38.380
methods.

01:38.380 --> 01:42.520
So which is f n equals n times.

01:42.520 --> 01:48.160
It depends how much data is being processed, which the data is n here.

01:48.160 --> 01:54.480
So we can use constants, for instance, C to calculate a lower bound and upper bound here.

01:54.490 --> 02:01.240
So now we're going to in next lecture, we're going to use the amortized analysis for this purpose.

02:01.270 --> 02:02.410
I'm waiting you in the next lecture.
