1
00:00:02,090 --> 00:00:02,840
Hi, everyone.

2
00:00:02,870 --> 00:00:08,420
So in this video, we are going to solve this question, print all the permutations of a string, so

3
00:00:08,420 --> 00:00:09,910
we need to print multiple notation.

4
00:00:10,100 --> 00:00:17,120
So if the string is A.B.C., then the permutations will be A.B.C. itself then Yaqub.

5
00:00:17,600 --> 00:00:18,670
So be easy.

6
00:00:19,400 --> 00:00:30,650
I have B, C, I have A, B and C, B, so in total there will be six permutation and because the length

7
00:00:30,650 --> 00:00:35,760
of the string history and the answer is three factorial antibacterials, three and 221.

8
00:00:36,230 --> 00:00:37,180
So this is six.

9
00:00:37,190 --> 00:00:43,070
So let's say in total there will be six one rotation and I need to print all the six permutation so

10
00:00:43,070 --> 00:00:45,310
we can solve this question with the help of recursion.

11
00:00:45,560 --> 00:00:50,920
So if this is our string abcde, how we will use equations so we will fix one element.

12
00:00:51,710 --> 00:00:53,090
So I will fix one element.

13
00:00:53,100 --> 00:00:56,600
Let's say I am fixing it and I will call that equation BCT.

14
00:00:57,530 --> 00:01:03,710
So the equation will print all the permutations of this string affixed, fixed and BCT will be and we

15
00:01:03,710 --> 00:01:05,269
will change the position of BCT.

16
00:01:05,720 --> 00:01:10,730
Similarly, I will fix the character B and I will call on Izadi.

17
00:01:11,950 --> 00:01:15,430
So the equation will paint, all the permutations would be fixed.

18
00:01:17,330 --> 00:01:22,130
So I will fix the elements, the characters, and I will call that equation on Verdie.

19
00:01:24,530 --> 00:01:31,540
So the question will print all the permutations and change this position and the position of courtesy

20
00:01:31,550 --> 00:01:32,340
will remain fixed.

21
00:01:33,290 --> 00:01:34,510
So finally, what will do?

22
00:01:35,270 --> 00:01:41,480
I will fix the character and I will call that equation on VXI.

23
00:01:42,600 --> 00:01:43,780
So what will you do?

24
00:01:44,400 --> 00:01:49,820
I will call let it go on this Eddie on this string and the guys will print all the permutation with

25
00:01:49,890 --> 00:01:51,590
the fixed sample.

26
00:01:51,780 --> 00:01:58,440
So what I need to do so if I'm standing here, so if this index is so first of all, I will be slapped

27
00:01:58,620 --> 00:02:03,540
with a sweep every day, then he is slapped with me.

28
00:02:03,690 --> 00:02:04,950
So I'm stepping in.

29
00:02:05,160 --> 00:02:09,120
So we will be fixed easily then I'm hoping I would see.

30
00:02:09,120 --> 00:02:10,560
So I am stepping in, see.

31
00:02:10,800 --> 00:02:17,490
So C will remain fixed and I have beardie and at last I will step this I so I will take a variable.

32
00:02:17,490 --> 00:02:17,910
I do.

33
00:02:17,910 --> 00:02:25,080
I read over the Eddie whatever the string and then I will step in with a B so then I will step Evett

34
00:02:25,440 --> 00:02:29,070
so they will come out first and it will come at the position of the.

35
00:02:29,310 --> 00:02:32,820
So we will call that it goes in on this, on this, on this and on this.

36
00:02:32,820 --> 00:02:36,630
And we will get all the permutations and all the permutation.

37
00:02:36,750 --> 00:02:37,260
Simple.

38
00:02:38,300 --> 00:02:44,900
Let us write the code and then we'll try it and also so that the function will be void as we will only

39
00:02:44,900 --> 00:02:47,180
print the name of the function is, let's say, permuted.

40
00:02:49,830 --> 00:02:51,570
Or let's print permutation.

41
00:02:53,060 --> 00:03:00,630
So Brent permutation, so it will take a pretty.

42
00:03:02,430 --> 00:03:07,970
And it will take the next day, so basically it is very simple if this thing is empty.

43
00:03:08,520 --> 00:03:11,520
So in that case, instead of a.

44
00:03:12,570 --> 00:03:15,450
Will be none, so if this is a situation.

45
00:03:18,180 --> 00:03:26,260
So in that case, I will simply have done so, first of all, I will print if this thing is empty,

46
00:03:26,280 --> 00:03:28,560
then the permutation will be empty string.

47
00:03:30,580 --> 00:03:31,540
And I will return.

48
00:03:32,780 --> 00:03:33,960
So this thing isn't pretty.

49
00:03:33,980 --> 00:03:38,120
I will bring to the emplacing because that will be the only one permutation and I will return.

50
00:03:39,470 --> 00:03:47,240
Otherwise, what we need to do so if you remember our approach was if you have A, B, C and D, so

51
00:03:47,240 --> 00:03:55,580
this is A so first of all, you will fix it and you will call on B, C, D, then you will fix B.

52
00:03:56,500 --> 00:04:06,060
And you will go a lot easier, then you will see and you will go a long beard and then you will fix

53
00:04:06,190 --> 00:04:09,190
these and you will call BCE.

54
00:04:10,060 --> 00:04:11,200
So basically, you can see.

55
00:04:11,470 --> 00:04:18,700
So I is first of all, getting stabbed with the eye, then character is getting so would be so be and

56
00:04:19,540 --> 00:04:20,140
then correct.

57
00:04:20,140 --> 00:04:25,960
Percy is getting stabbed every day so she will come out first and is getting any and they will reach

58
00:04:25,960 --> 00:04:28,980
the position of the is coming at first.

59
00:04:28,990 --> 00:04:30,700
So it will reach the position of the.

60
00:04:30,730 --> 00:04:32,200
So we are swapping the characters.

61
00:04:32,560 --> 00:04:37,360
So for the characters, what we will do, we will use a for loop, we will use a follow up to the string

62
00:04:37,360 --> 00:04:38,170
and we will swap.

63
00:04:40,500 --> 00:04:49,290
So we need to slap and call dedication, so let's take over the due to our trade and we need to wait

64
00:04:49,320 --> 00:04:51,360
till Jay's not only.

65
00:04:54,860 --> 00:04:59,470
Jay Placeless, so what we need to do, we need to slap a high-energy.

66
00:05:00,990 --> 00:05:05,400
So I'm stepping away and so after the stepping.

67
00:05:07,980 --> 00:05:12,060
So after stopping what they need to do, I will call the function Brint permutation.

68
00:05:16,550 --> 00:05:23,600
And I will give Eddie and I plus one, so I think this will be string.

69
00:05:25,020 --> 00:05:28,320
Slap the string, I attend position.

70
00:05:30,150 --> 00:05:31,530
So what is happening here is.

71
00:05:33,170 --> 00:05:33,560
S..

72
00:05:36,120 --> 00:05:40,230
So this is the value of I, I will pass the value of I zero.

73
00:05:40,670 --> 00:05:43,530
So do you start from Zero and Piland?

74
00:05:43,530 --> 00:05:45,030
So I will trade Tail-End.

75
00:05:46,390 --> 00:05:54,040
So what I'm doing, I'm stepping in, so it will be with first, because the value of G is initially

76
00:05:54,070 --> 00:05:56,140
the value of G is that same position.

77
00:05:56,170 --> 00:06:01,870
OK, so he will be able to viddy and then you need to call the equation on this etty so string and I

78
00:06:01,870 --> 00:06:02,240
plasm.

79
00:06:02,320 --> 00:06:03,250
So this is a plus.

80
00:06:03,460 --> 00:06:05,680
OK then what will happen.

81
00:06:05,860 --> 00:06:09,700
So Recordset will print all the permutation and then the equation will come back.

82
00:06:11,630 --> 00:06:18,420
So after coming back plus so I will reach here, you will reach here and then what you are doing us

83
00:06:18,440 --> 00:06:24,680
shopping, I think we are again sapping our energy source that this will become BCT and then you will

84
00:06:24,680 --> 00:06:27,970
call the permutation, so you will call the permutation on this.

85
00:06:28,640 --> 00:06:32,620
So the question will do all the work records, will print all the permutation and we will return.

86
00:06:33,020 --> 00:06:35,510
But see, this is the correct response to my reference.

87
00:06:35,760 --> 00:06:39,270
So you when you will return, you will return BCT.

88
00:06:39,980 --> 00:06:41,660
Orginally it should be ABCDE.

89
00:06:41,720 --> 00:06:43,880
So what I want to say is.

90
00:06:44,960 --> 00:06:46,130
Yunta slap again.

91
00:06:47,690 --> 00:06:50,480
After printing the permutation, you need to start again.

92
00:06:53,100 --> 00:06:54,590
You need to set one more time.

93
00:07:00,240 --> 00:07:02,800
See why you need to start one more time.

94
00:07:04,290 --> 00:07:06,750
This is your string ABC simple.

95
00:07:07,170 --> 00:07:09,570
So let's say and we are getting swabbed.

96
00:07:09,930 --> 00:07:13,020
So if you and we are getting swabbed, this will become B.

97
00:07:14,260 --> 00:07:18,880
And you will call that on AC, you will call Erica on AC and.

98
00:07:19,920 --> 00:07:24,930
You will call the permutations of permutation function will print all the permutations, so now your

99
00:07:24,930 --> 00:07:26,350
character is busy.

100
00:07:27,270 --> 00:07:29,000
Now your character is busy.

101
00:07:29,010 --> 00:07:30,460
I believe it should be ABC.

102
00:07:30,840 --> 00:07:38,100
So to get back to the situation, to get back to the situation, you need to step up and be again similarly

103
00:07:38,520 --> 00:07:39,590
when you will step in.

104
00:07:40,590 --> 00:07:43,140
So this will be easy and then be.

105
00:07:44,820 --> 00:07:49,200
You will print all the permutations, you will call the recursion, then if you want to go back to this

106
00:07:49,200 --> 00:07:54,990
position, you need to see and again, so I need to step after data collection is over.

107
00:07:55,200 --> 00:08:00,170
So after data collection work is done, after the recording is over, to go back to the original state,

108
00:08:00,180 --> 00:08:03,930
I need to do something again to go back to the original state.

109
00:08:03,930 --> 00:08:06,620
After the work of recording is done, I need to show again.

110
00:08:06,630 --> 00:08:10,200
So that's why you need to step after the work of records is over.

111
00:08:11,400 --> 00:08:13,890
Simple, so I think our function will work.

112
00:08:14,070 --> 00:08:14,730
So let's.

113
00:08:15,840 --> 00:08:18,780
Let's test our function and then we will write a novel called.

114
00:08:20,700 --> 00:08:22,560
So what is our function?

115
00:08:22,590 --> 00:08:23,850
Let's take a string.

116
00:08:26,750 --> 00:08:28,130
So I was doing is ABC.

117
00:08:34,539 --> 00:08:36,370
And let's call the function permutation.

118
00:08:41,309 --> 00:08:48,810
So this is a spent permutation, I will pass the string and let's take default argument, so instead

119
00:08:48,810 --> 00:08:52,500
of passing the value of a default argument, I'm using default argument.

120
00:08:53,040 --> 00:08:54,470
So I think our function will work.

121
00:08:54,480 --> 00:08:55,020
Solarte.

122
00:08:56,920 --> 00:09:02,380
So basically, these are all permutation, so let's see how our function will work, let's try to find

123
00:09:02,380 --> 00:09:02,670
out.

124
00:09:02,710 --> 00:09:04,300
So the input is basically ABC.

125
00:09:06,080 --> 00:09:10,260
So this is an exciting and you will trade and you will swap.

126
00:09:10,640 --> 00:09:14,300
So there are three conditions you are treating and you are stepping.

127
00:09:14,780 --> 00:09:20,930
So first step, I will show up every day and then you will call dedication on NBC.

128
00:09:22,280 --> 00:09:30,320
So we will step in and be and then you will call that equation easy, you will stop and see and you

129
00:09:30,320 --> 00:09:37,520
will call that equation B. So now B will start with B again.

130
00:09:38,240 --> 00:09:41,180
So in this case, there will be two possible.

131
00:09:41,200 --> 00:09:41,720
So again.

132
00:09:43,350 --> 00:09:50,310
Slapping after slapping two kisses will be there and be and we'll call that equation, see then I have

133
00:09:50,310 --> 00:09:53,990
and I will call that a question on B here.

134
00:09:54,000 --> 00:09:56,480
I have been there and I will call you Nancy.

135
00:09:56,880 --> 00:10:00,070
And here I have BNC and I will call that occasionally.

136
00:10:00,780 --> 00:10:04,080
Similarly, here I can be and I will call it occasionally.

137
00:10:04,770 --> 00:10:05,700
Here I see.

138
00:10:05,730 --> 00:10:07,800
And I and I will call dedication on me.

139
00:10:09,180 --> 00:10:10,730
So again, what will happen?

140
00:10:10,740 --> 00:10:12,270
So since there is only one element.

141
00:10:12,690 --> 00:10:15,780
So this is ABC, there's only one element.

142
00:10:15,780 --> 00:10:17,270
So no need to do anything.

143
00:10:17,280 --> 00:10:18,210
This will be HCB.

144
00:10:19,080 --> 00:10:23,250
This is B, C, this is B.K..

145
00:10:24,450 --> 00:10:27,890
This is CBS and this is CAIB.

146
00:10:29,310 --> 00:10:34,980
So you can match the output, ABC, F.S.B, so ABC Yaqub.

147
00:10:36,030 --> 00:10:46,920
BSE, BCT, BSE, busy, then CBA, so we have Seeb, then I haven't CHB, so then I have CAIB, so

148
00:10:46,920 --> 00:10:49,020
basically our function is working properly.

149
00:10:49,350 --> 00:10:51,440
OK, so this is from this video.

150
00:10:51,600 --> 00:10:52,840
I will see you in the next one.

151
00:10:52,860 --> 00:10:53,340
Thank you.

