1 00:00:00,410 --> 00:00:05,030 In the previous example, we calculated the complexity of the iterative method. 2 00:00:05,030 --> 00:00:07,250 So now let's do it with the recursive method. 3 00:00:07,250 --> 00:00:07,400 Here. 4 00:00:07,400 --> 00:00:14,030 Suppose we need to calculate the fraction of a certain number, for instance, six, which will produce 5 00:00:14,030 --> 00:00:14,900 here. 6 00:00:15,110 --> 00:00:21,530 Actually, let's make this here for example, we want to create something like that six fractional number 7 00:00:21,530 --> 00:00:27,890 six and which will produce the six fraction equals here. 8 00:00:28,820 --> 00:00:40,670 Six, multiply by five, multiply by four, multiply by three, two and one, which is equal to 27 720. 9 00:00:42,140 --> 00:00:44,570 So for this purpose we can use the recursive method. 10 00:00:44,570 --> 00:00:49,010 So which is we're going to write this in this lecture. 11 00:00:49,010 --> 00:00:54,560 So here let's actually create a new method named Integer Fractional. 12 00:00:56,270 --> 00:00:58,850 Or factorial, factorial. 13 00:00:58,970 --> 00:01:03,710 And here we this will get a new integer n here. 14 00:01:03,980 --> 00:01:06,230 And now if our. 15 00:01:07,370 --> 00:01:12,110 N is equal to one, then return one. 16 00:01:12,750 --> 00:01:14,580 Signs here. 17 00:01:16,850 --> 00:01:24,470 And, uh, else, if it's not uh, executed, then return and multiply by a fractional fraction. 18 00:01:25,630 --> 00:01:26,530 Factorial. 19 00:01:27,550 --> 00:01:28,780 N minus one. 20 00:01:29,440 --> 00:01:31,060 That's our function. 21 00:01:31,060 --> 00:01:37,750 So for the preceding function, we can calculate the complexity of this similarly to how we did in iterative 22 00:01:37,750 --> 00:01:38,380 methods. 23 00:01:38,380 --> 00:01:42,520 So which is f n equals n times. 24 00:01:42,520 --> 00:01:48,160 It depends how much data is being processed, which the data is n here. 25 00:01:48,160 --> 00:01:54,480 So we can use constants, for instance, C to calculate a lower bound and upper bound here. 26 00:01:54,490 --> 00:02:01,240 So now we're going to in next lecture, we're going to use the amortized analysis for this purpose. 27 00:02:01,270 --> 00:02:02,410 I'm waiting you in the next lecture.