Hi, everyone.
So in this video, we are going to solve this question, print all the permutations of a string, so
we need to print multiple notation.
So if the string is A.B.C., then the permutations will be A.B.C. itself then Yaqub.
So be easy.
I have B, C, I have A, B and C, B, so in total there will be six permutation and because the length
of the string history and the answer is three factorial antibacterials, three and 221.
So this is six.
So let's say in total there will be six one rotation and I need to print all the six permutation so
we can solve this question with the help of recursion.
So if this is our string abcde, how we will use equations so we will fix one element.
So I will fix one element.
Let's say I am fixing it and I will call that equation BCT.
So the equation will print all the permutations of this string affixed, fixed and BCT will be and we
will change the position of BCT.
Similarly, I will fix the character B and I will call on Izadi.
So the equation will paint, all the permutations would be fixed.
So I will fix the elements, the characters, and I will call that equation on Verdie.
So the question will print all the permutations and change this position and the position of courtesy
will remain fixed.
So finally, what will do?
I will fix the character and I will call that equation on VXI.
So what will you do?
I will call let it go on this Eddie on this string and the guys will print all the permutation with
the fixed sample.
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
with a sweep every day, then he is slapped with me.
So I'm stepping in.
So we will be fixed easily then I'm hoping I would see.
So I am stepping in, see.
So C will remain fixed and I have beardie and at last I will step this I so I will take a variable.
I do.
I read over the Eddie whatever the string and then I will step in with a B so then I will step Evett
so they will come out first and it will come at the position of the.
So we will call that it goes in on this, on this, on this and on this.
And we will get all the permutations and all the permutation.
Simple.
Let us write the code and then we'll try it and also so that the function will be void as we will only
print the name of the function is, let's say, permuted.
Or let's print permutation.
So Brent permutation, so it will take a pretty.
And it will take the next day, so basically it is very simple if this thing is empty.
So in that case, instead of a.
Will be none, so if this is a situation.
So in that case, I will simply have done so, first of all, I will print if this thing is empty,
then the permutation will be empty string.
And I will return.
So this thing isn't pretty.
I will bring to the emplacing because that will be the only one permutation and I will return.
Otherwise, what we need to do so if you remember our approach was if you have A, B, C and D, so
this is A so first of all, you will fix it and you will call on B, C, D, then you will fix B.
And you will go a lot easier, then you will see and you will go a long beard and then you will fix
these and you will call BCE.
So basically, you can see.
So I is first of all, getting stabbed with the eye, then character is getting so would be so be and
then correct.
Percy is getting stabbed every day so she will come out first and is getting any and they will reach
the position of the is coming at first.
So it will reach the position of the.
So we are swapping the characters.
So for the characters, what we will do, we will use a for loop, we will use a follow up to the string
and we will swap.
So we need to slap and call dedication, so let's take over the due to our trade and we need to wait
till Jay's not only.
Jay Placeless, so what we need to do, we need to slap a high-energy.
So I'm stepping away and so after the stepping.
So after stopping what they need to do, I will call the function Brint permutation.
And I will give Eddie and I plus one, so I think this will be string.
Slap the string, I attend position.
So what is happening here is.
S..
So this is the value of I, I will pass the value of I zero.
So do you start from Zero and Piland?
So I will trade Tail-End.
So what I'm doing, I'm stepping in, so it will be with first, because the value of G is initially
the value of G is that same position.
OK, so he will be able to viddy and then you need to call the equation on this etty so string and I
plasm.
So this is a plus.
OK then what will happen.
So Recordset will print all the permutation and then the equation will come back.
So after coming back plus so I will reach here, you will reach here and then what you are doing us
shopping, I think we are again sapping our energy source that this will become BCT and then you will
call the permutation, so you will call the permutation on this.
So the question will do all the work records, will print all the permutation and we will return.
But see, this is the correct response to my reference.
So you when you will return, you will return BCT.
Orginally it should be ABCDE.
So what I want to say is.
Yunta slap again.
After printing the permutation, you need to start again.
You need to set one more time.
See why you need to start one more time.
This is your string ABC simple.
So let's say and we are getting swabbed.
So if you and we are getting swabbed, this will become B.
And you will call that on AC, you will call Erica on AC and.
You will call the permutations of permutation function will print all the permutations, so now your
character is busy.
Now your character is busy.
I believe it should be ABC.
So to get back to the situation, to get back to the situation, you need to step up and be again similarly
when you will step in.
So this will be easy and then be.
You will print all the permutations, you will call the recursion, then if you want to go back to this
position, you need to see and again, so I need to step after data collection is over.
So after data collection work is done, after the recording is over, to go back to the original state,
I need to do something again to go back to the original state.
After the work of recording is done, I need to show again.
So that's why you need to step after the work of records is over.
Simple, so I think our function will work.
So let's.
Let's test our function and then we will write a novel called.
So what is our function?
Let's take a string.
So I was doing is ABC.
And let's call the function permutation.
So this is a spent permutation, I will pass the string and let's take default argument, so instead
of passing the value of a default argument, I'm using default argument.
So I think our function will work.
Solarte.
So basically, these are all permutation, so let's see how our function will work, let's try to find
out.
So the input is basically ABC.
So this is an exciting and you will trade and you will swap.
So there are three conditions you are treating and you are stepping.
So first step, I will show up every day and then you will call dedication on NBC.
So we will step in and be and then you will call that equation easy, you will stop and see and you
will call that equation B. So now B will start with B again.
So in this case, there will be two possible.
So again.
Slapping after slapping two kisses will be there and be and we'll call that equation, see then I have
and I will call that a question on B here.
I have been there and I will call you Nancy.
And here I have BNC and I will call that occasionally.
Similarly, here I can be and I will call it occasionally.
Here I see.
And I and I will call dedication on me.
So again, what will happen?
So since there is only one element.
So this is ABC, there's only one element.
So no need to do anything.
This will be HCB.
This is B, C, this is B.K..
This is CBS and this is CAIB.
So you can match the output, ABC, F.S.B, so ABC Yaqub.
BSE, BCT, BSE, busy, then CBA, so we have Seeb, then I haven't CHB, so then I have CAIB, so
basically our function is working properly.
OK, so this is from this video.
I will see you in the next one.
Thank you.