Hi, everyone.
So in this very day, we will start writing the code for dysfunction, so we are taking in order to
as important as input, but we discussed in our previous video that I need to create a function like
this.
I will create a function and I will pass in order to start, in order to start and end.
So let's create this function and we will name it helper function.
So what?
This helper function will return.
So it will be down the road, so try not start the name of the function will be built to help, so normal
function is build the helper.
So it will take in order traversal.
So it will take in order to as input.
It will take.
Bulstrode traversal as input.
And we know it will start in order to start Bulstrode around.
So.
In order.
Start.
In order and.
Let's start.
Bulstrode and.
And this function will return the there and how we will call this function.
So in the end is equal to the door, says.
So you can also use Rhodes's size or poster or size, basically the number of elements will be seen.
So in order that size and we will call this function will helper.
So they've done very little helper.
I will pass in order.
I will pass in order, Eddie.
So dysfunctioning need also that I also saw a post already.
This function need to start in order, and so in order to start the index is zero in order and indexes
and minus one Bulstrode start is zero.
Order that and indexes and minus one.
Simple, so now dysfunction is a recursive function.
So first let us discuss about the case.
So this case is basically empty and so far empty at the start will be greater than in order and order.
You can also use Bulstrode.
Astarte is guerdon order.
And so that means ampitheater and for ampitheater military will be empty.
I am returning then.
So biscuits is now ready.
And what is our approach?
So let me write it here.
Our approach is very simple.
I want to I will create the root node and then I will colocation for building the left subtree.
I will call the kitchen for building the right subtree.
So for creating the root that we know we need to find out the root data and what is the root data.
So in the post retriever's first we print the left Sabry then we print that I etc and then we print
the root data.
So the last element for the post traversal.
So we need to find out the last element.
So what is little data so integer?
Raw data is basically the last element of the poster that said, let's copy this supposed order edit
and we need to give the last index so you will give a boost and.
So opposed.
And so now we know the route data and we need to find out the values of the variables.
So in detail, we need left in order to start.
We need to find out left in order, and similarly, we need to find out left Bulstrode Astarte.
Left both to end and similarly, the forward values for the right tree so that we can build the right
subtree, so a right in order to start.
Right, in order and.
Right.
Bulstrode Astarte.
And right.
And so if we will be able to find out all these great values, then what we can do.
So first step was building the road.
So we know the route data.
We know the route.
So let's build the road.
So the North Star.
Route.
Is your DNA and we will pass the down, so now our Rudy is ready.
So what we need to do after finding out the truth, after constructing the route, we will call, we
will build the subtree and then we will build the right subtree.
So first, let us build the SIPRI.
So, Bill, the left subtree, so rude and left, is for building the left subtree with the help of
this function.
Military helper, I will give this in order that I need to pass the order ready.
I need to pass postmodernity.
I need to pass the start for the left, I'm calculating left.
I am constructing left, so I will pass left in order to start.
Then in order and so I'm constructing left subtree, so left in order and.
Then left Bulstrode start because I'm building left subtree and left posterboard around because I'm
building the left sempre so now your left the prison already.
So now let us build our right subtree so we will take the help of this function military helper.
Let's call this function so this function needs the ordinary.
This function also needs the poster today.
Then this function needs the start, since I'm building the right subtree, so I will give right in
order to start.
Then I will give right in order and.
Then I will give right Bulstrode start.
And then I will give right boaster and.
So now what is a situation so I have constructed this route not.
With the help of discord and then I am building that tree and I am passing the left in order that it
and the left already.
So this tree will be constructed and then I am making the connection.
So connection has been established.
Then I'm calling the function for building the right subtree.
So I am passing right in order and right.
Bulstrode.
So this tree will be constructed and then I am attaching.
So then this connection has been established.
For now the tree is ready and we will return the room.
So let's return the root.
So now we will return that.
So now everything is ready.
The one thing left, so everything is ready.
Everything will work fine.
Now we need to find out these eight values.
And we already collected these eight values in our previous video.
So if you will see, these are the values we have calculated.
OK, so let's put it.
So what is left in order to start this is in order to start.
So left in order to start.
Is same as.
In order to start.
So what is left in order and it is the next minus one, we will find out through the next.
Also, let's write it here.
So next minus one.
Left Bulstrode Astarte, so the system is supposed to restart.
So this is Sam's story to start.
So the system is supposed to restart left Bulstrode and.
So left to right and left for the start, plus left in order and minus left in the start.
So this is left Boston to start.
Plus, left in order to end.
Minus left in order to start.
So what is riding on that start?
Right, in order to start this route and express one.
So we will tell you next.
Also, first ladies right here.
So this is routine X plus one.
Right, in order and in order, and so this is in order and.
So right in order and as Sams and.
So what is right to restart the right, both to restart this left end, plus one left coast and plus
one so left coast and plus one?
Plus one.
Right poster that this post and minus one.
So this is post and minus one.
So now we have the majority of the code, we have written the code for the majority of the problem.
So now everything is ready.
We just need to find out this root index so we'll find out the root index exactly like the previous
problem.
So what we need to do.
So this is your order.
So you have the left subtree, then the root and then the right separate.
And what is the posterior traversal?
So first your print left, then you print right subtree and then you print the root.
So we have the root data, we have the root data.
So we will search through data in the area so that all the time that area will be able to find out the
root data.
So this is called root index.
So let's try to find out the truth the next.
So let's find the root index so initially.
The crude index is minus one now.
We will trade over the area, so I will start from in order to start.
I will search till in order and I placeless.
So if.
In order.
So if in order I.
Is it close to the true data?
Then we know what is the root index, so index is a root index is a and we will break.
So, again, I am repeating exactly the same thing.
So our solution is assuming no duplicates.
So the question also is duplicate does not exist because of duplicate exist, then our code will not
work.
OK, for example, if the data is for there are two forms in the room and in the left separate.
So we will find out for here also.
So basically you will not be able to construct or duplicate does not exist.
And the input is right.
If the input is wrong, basically the value of the next at this line, if the value of the index is
still minus.
That means your input is wrong and we will assume that the input is right.
So I think that is the code that we need to write.
So let's have a good first line of code and then we will submit.
So in order to meet our goal.
So, yes, basically, our goal is working success, so this is it from this video, I will see you
in the next one.
Thank you.