1 00:00:02,160 --> 00:00:02,880 Hi, everyone. 2 00:00:02,910 --> 00:00:09,630 So in this video, we will apply the recursion on Kripalani, so for example, if this is Michael A.B.C., 3 00:00:10,830 --> 00:00:12,990 so let's try to write a function print. 4 00:00:13,970 --> 00:00:20,000 So this brain function will print ABC and we will also write one more function, reverse print. 5 00:00:21,690 --> 00:00:24,630 So the output of REWASH print will be S.B. 6 00:00:25,290 --> 00:00:28,500 So let's start the course for these two function, print and reverse print. 7 00:00:28,830 --> 00:00:30,640 So what will the gold of print function? 8 00:00:30,960 --> 00:00:32,290 So this is our area. 9 00:00:32,580 --> 00:00:33,120 This is our. 10 00:00:34,140 --> 00:00:35,700 I want to print this area. 11 00:00:36,060 --> 00:00:39,240 So what I will do, I will print the first index. 12 00:00:39,250 --> 00:00:40,890 So I will print AOF zero. 13 00:00:43,030 --> 00:00:49,510 I will do very small work, so I will print this value and then I will apply to go on this Eddie so 14 00:00:49,660 --> 00:00:51,720 recordation will print this, Eddie. 15 00:00:52,140 --> 00:00:57,560 OK, so this is a very pleasant if this is a this is a blessing. 16 00:00:57,850 --> 00:00:59,470 So now let us write the code. 17 00:01:02,090 --> 00:01:05,420 So I just want to bring to the area so that it will be void, Brent. 18 00:01:06,600 --> 00:01:10,950 I don't think it is, but let's say the name of that is in prudery. 19 00:01:12,600 --> 00:01:15,850 So basically, this is basically when it is empty. 20 00:01:16,110 --> 00:01:20,370 So if it is empty, that means in part of zero will be none. 21 00:01:21,270 --> 00:01:22,680 So this is our best case. 22 00:01:26,760 --> 00:01:31,980 So in this case, if I were in, that is basically empty, so we will not do anything, we will simply 23 00:01:31,990 --> 00:01:32,370 return. 24 00:01:33,330 --> 00:01:34,600 Otherwise what will do? 25 00:01:35,430 --> 00:01:36,890 So I will do very small work. 26 00:01:37,290 --> 00:01:40,010 So our plan is very simple, what we will do. 27 00:01:40,530 --> 00:01:41,910 So I want to bring to this area. 28 00:01:43,400 --> 00:01:48,830 I will bring the first element, so I will print off zero is basically the three, so here there is 29 00:01:48,830 --> 00:01:52,760 input, so I will bring the first element and then I will apply the question. 30 00:01:52,950 --> 00:01:54,750 The question will print this smaller. 31 00:01:55,700 --> 00:01:57,050 So let me do my work. 32 00:01:57,590 --> 00:02:01,370 So I just I will just print the first Trelew. 33 00:02:03,670 --> 00:02:08,270 Let's simplify it like this and what will happen, the coalition will print everything else. 34 00:02:08,650 --> 00:02:12,190 So let's call this function print and I will give the rest of that. 35 00:02:13,060 --> 00:02:17,970 So I will give input plus one and my area will be printed simple. 36 00:02:18,310 --> 00:02:19,640 So that is all that we need to do. 37 00:02:20,530 --> 00:02:23,050 So let's call this function print. 38 00:02:23,220 --> 00:02:24,580 Let's create a Barry. 39 00:02:29,700 --> 00:02:30,930 So Eddys, ABC. 40 00:02:32,340 --> 00:02:35,700 And it's called a function Brent and Bassendean prudery. 41 00:02:37,550 --> 00:02:39,560 So output should be A.B.C.. 42 00:02:43,110 --> 00:02:49,770 So now is ABC, so our function is working, so I told you we will do two things so our brain function 43 00:02:49,770 --> 00:02:50,160 is ready. 44 00:02:50,940 --> 00:02:53,890 So what we do now, we will also write the code for reverse spend. 45 00:02:54,270 --> 00:02:57,060 So let's discuss how we can write the code for replacement. 46 00:02:59,080 --> 00:03:04,320 So basically right now, what I'm doing so in this case, what I'm doing when I am printing normal, 47 00:03:04,690 --> 00:03:08,990 so first I am printing this value and then I am calling recursion. 48 00:03:09,510 --> 00:03:15,640 So if I want to print, if I want to print in reverse order, if I want to print in reverse order, 49 00:03:15,640 --> 00:03:16,260 what will I do? 50 00:03:18,100 --> 00:03:20,260 First, I will print this, Harry. 51 00:03:21,400 --> 00:03:25,010 So first I will print this Harry, and then I will print this value. 52 00:03:25,330 --> 00:03:29,040 So basically the order will be reversed and everything myself. 53 00:03:29,290 --> 00:03:34,510 So currently in this in normal printing, first printing, this element and then we are printing this, 54 00:03:34,510 --> 00:03:34,760 Harry. 55 00:03:35,350 --> 00:03:39,370 So we are printing normally, but in the reverse order print what we will do. 56 00:03:39,490 --> 00:03:43,080 First of all, print this, Harry, and then we will print this element. 57 00:03:43,330 --> 00:03:45,840 So basically our order of printing will be reversed. 58 00:03:46,660 --> 00:03:49,590 So we just need to reverse the order of these two calls. 59 00:03:50,410 --> 00:03:51,880 So let's create another function. 60 00:03:55,160 --> 00:03:59,570 So this is void, letting a real function is reverse sprint. 61 00:04:01,240 --> 00:04:01,830 Told Dick. 62 00:04:04,890 --> 00:04:09,170 It is in this case will remain him, so let's copy this. 63 00:04:12,140 --> 00:04:16,010 My guests will be him, and first we will call that equation. 64 00:04:18,200 --> 00:04:20,440 So first print the rest of that done. 65 00:04:20,640 --> 00:04:23,240 The function is reverse print. 66 00:04:23,900 --> 00:04:27,380 So first print the rest of that and then print the current element. 67 00:04:32,320 --> 00:04:37,080 So what I'm saying here is C. So what will happen this is already. 68 00:04:38,010 --> 00:04:43,740 So I am standing here, so this element will say, do not bring to me if the rest of the area, so I 69 00:04:43,740 --> 00:04:44,810 will come at this element. 70 00:04:44,820 --> 00:04:47,990 So this element will say, do not bring to me first, bring the rest to daddy. 71 00:04:48,300 --> 00:04:49,830 I will come at this element. 72 00:04:50,040 --> 00:04:53,250 So this element will say, do not bring to me a footprint rest of the area. 73 00:04:53,280 --> 00:04:56,680 So first you are bringing rest of the area and then we are bringing the current element. 74 00:04:57,120 --> 00:05:03,410 So finally, at this point, you do not want to me for the rest of the area so that it does not exist. 75 00:05:03,420 --> 00:05:04,250 So we will return. 76 00:05:04,470 --> 00:05:06,750 So when we will be done now, we will bring this value. 77 00:05:06,990 --> 00:05:11,040 So then we will bring this value, then we will bring this value and so on. 78 00:05:11,190 --> 00:05:13,230 And at last we will print this value. 79 00:05:14,920 --> 00:05:20,470 So let's take one example and let's build this school, so let's do it in first Discworld ABC. 80 00:05:20,950 --> 00:05:21,790 So what will happen? 81 00:05:24,310 --> 00:05:26,330 So first of all, this is my output. 82 00:05:26,350 --> 00:05:29,080 So I will print it and I will call dedication NBC. 83 00:05:30,570 --> 00:05:32,990 Now, I will bring to be and I will call for. 84 00:05:34,590 --> 00:05:41,750 So now I will Bentzi and I will call the ABC and then so we have also so then we will call on the empty 85 00:05:41,760 --> 00:05:42,230 Adonal. 86 00:05:42,420 --> 00:05:47,370 So when you encounter Nylander done so we will return and we are not doing anything, so we will simply 87 00:05:47,370 --> 00:05:47,700 return. 88 00:05:47,700 --> 00:05:51,110 And this is the output A.B.C. So let's check for this, how it will work. 89 00:05:51,420 --> 00:05:53,970 So let's take the same example, ABC. 90 00:05:56,050 --> 00:05:57,310 And this is my output. 91 00:05:58,520 --> 00:06:02,960 So what will happen, he will say, do not paint me first, paint the rest of the day, so I will call 92 00:06:02,960 --> 00:06:03,530 on ABC. 93 00:06:04,770 --> 00:06:07,610 We will say do not paint me for the rest of the 80s. 94 00:06:07,610 --> 00:06:08,660 So I will call Nancy. 95 00:06:09,570 --> 00:06:12,140 He will say, do not paint me for the rest of the area. 96 00:06:12,140 --> 00:06:14,420 So I will call ONAL so we have none here. 97 00:06:15,140 --> 00:06:17,400 So when we encounter Nael, we will return. 98 00:06:17,780 --> 00:06:19,280 When we encounter we will return. 99 00:06:19,580 --> 00:06:24,020 So when we are returning, after the election is over, we will bring the current Telemann. 100 00:06:24,020 --> 00:06:24,860 So I will princi. 101 00:06:25,250 --> 00:06:27,490 So when we will return, we will bring the current elements. 102 00:06:27,500 --> 00:06:28,220 I will bring Debbie. 103 00:06:28,490 --> 00:06:34,430 So when we are done, we are bringing the current elements of current element is so easily printed. 104 00:06:34,430 --> 00:06:36,220 So that's how the output will be Seeb. 105 00:06:36,230 --> 00:06:37,430 So this is a reverse print. 106 00:06:38,060 --> 00:06:39,440 So let's test this also. 107 00:06:40,700 --> 00:06:42,590 It's called the function reverse sprint. 108 00:06:44,190 --> 00:06:45,570 And I will pass and put. 109 00:06:47,900 --> 00:06:51,900 So let's give one timeline here so that we can see it clearly. 110 00:06:52,400 --> 00:06:54,910 So let's call the function, let's say, an hour file. 111 00:06:55,190 --> 00:06:57,980 So output is ABC and then we have c.B. 112 00:06:59,310 --> 00:07:01,060 So that's how it is working. 113 00:07:01,260 --> 00:07:02,700 So this is it from this video. 114 00:07:02,730 --> 00:07:03,870 I will see you in the next one.