Hi, everyone.
So in this video, we are going to solve this question, bent all the positions of the element.
So given an area, let's say the area has elements five, five, six, five and six.
And let's say the index are zero, one, two, three and four.
So they will be available to the value of X is five.
So five is present zero at the next one and at the next three.
So you need to print all the position.
So I will bring to zero.
I will print one, I will print three.
Let's say the value of X is six, so six is present at next to at the next four and we need to print
all the positions of the element.
So I will print it next to I will print the next four, let's say, the value of existence.
So ten is not present in this area, so I will not print anything simple answer the problem.
So very simple way to solve this problem is using four Lopevi loop and how we can solve this problem.
Just write it over and as soon as you find the element, just print the index and move ahead.
So as soon as you again find the element, print the index and continue updating our.
So when you reach the end of that, you will stop iterating and then you have to do it answered.
So since we are learning religion, so we will solve this problem using recursion and we can use exactly
the same approach, what we will do.
So we will treat ordinary.
We will light it over the area, we need to get it over the area and we are using recursion so we know
how to iterate over the area using recursion.
So we just need to take a variable eye so we already see how we can get it over the area.
Using recursion just need to maintain a variable eye.
So I will start from zero when I when I will reach and I will stop.
So let's write the cold, so let's see, I don't have the function will be void because I'm only printing,
so print all we need to print all position, so print all.
Position, I will take Eddie as input.
I will take and I will take it next, I do it right over the edge.
So if.
If I Regis and that means we need to stop, so return, I am stopping, otherwise check.
So if I.
Is it close to X, so we need to take X also.
So if I equals X, I have to spend the next Soucy out, I.
And call that equation, we need to move ahead, we will not stop.
OK, so here after printing the eight, we will not stop by trading the we need to continue our trading
over till we reach the last index index.
And so print all position, we will not stop.
We need to move ahead.
So E and.
And I plus one move ahead, so I think our function will work.
Let's copy this function Brendel position.
So a number of elements, six, let's say, I want to paint, I want to find out all the index of five.
I will start from zero.
See how this function is working.
So this is our area.
Five, five, six, five, six and seven, so I am putting the value of a which is zero.
So I is standing here, so I will check.
And the value of X is basically five.
So five equals five.
Yes, Brent I the value of zero.
So this is my output.
So I will print zero and then move ahead.
So I will come here.
So this is next recursion call.
OK, and it will not change and will not change.
So this is next recording.
Call this as I say again, five equals five, the value of Axis five.
So we will print one next equation call.
I will come here.
So six equals five do not do anything.
So move ahead.
So I will move.
This is the next recording call I will print.
So the next fight is basically three.
I will print three and then move ahead.
So six is not close to five Movahed.
Seven is not close question, five more world, so I will reach the last six and then they're done and
this is my output zero one three.
So, Richard, zero three.
And the output is zero one entry.
Let's say I want to search for sex, for sex output should be this zero one, two, three and four output
should be two and four.
So I put this to end for now, let's try to search for seven.
Output should be five.
And output is coming out to be five and let's try one case.
In which the element does not present, so then is not present inside the.
So I will not bring anything.
So I'm not printing anything.
So our function is working, so this is it from this video.
I will see you in the next one.