Hi, everyone, welcome to this new video.
So in this video, what we are going to do is we are going to build one try of dictionary.
We are going to build one tree of dictionary.
And this is my dictionary.
So correctly, dictionary is containing these words and I need to build one tree out of it.
Right.
So we have discussed how that will look like.
So first I will have the root node and then basically also create a node with data and then create a
node with a data R and create a node with data.
And since E is the last node, so what we will do, you will also highlight this node.
So we need to insert all these words.
We need to insert all these words in our trade as actual simple.
Right.
So what we need to do, first of all, we need to define what is this node?
What is this node?
So basically this let's say the name of the node is try node.
So we're destroying all this, containing it will contain data, some data and the data is off type
character.
So I will have something like character data.
What else it will contain, so it will contain like whether the given node is a terminal node or not.
Right.
But given all is a terminal or not.
So it will contain something, a ball type ball, whether terminal or not.
So is terminal.
What else it will contain, so see for a how many possibilities, how many trials can be there?
So currently I have one child.
If I insert this character, this word, sorry, so I will have one more node.
So now it has to child it has two child otterness.
So that makes how many trials can be delayed.
So I think at the max there can be 26 trials because we have 26 alphabet's.
Right.
So what we need to do, we need to create one area of trials also.
So array of trials basically and trial is of type.
So this is a trial and jail is also a trial.
All right.
This trial is also a..
And notice basically to astronaut and this this node is appointed to this node.
So that's a appointer to trial.
And how many trials?
26 trials.
So what I'm trying to say here is how the node will look like.
So it will look like this.
This is a..
It is containing whether this is terminal or not.
So for the node A, this is known terminal.
So this Norn terminal, since this is known, it will store false value and there will be a re.
Offsiders, 26.
And this will contain the pointer to the next and similarly, this will contain pointer to the next
node and so on.
And if there are no pointers, then this will store null value.
Simple, right?
If there are no pointers, then I will null value.
And in fact, since we have this, Eddie, I don't think we need this data member.
We don't need to store study.
Why?
How will I story.
So it will correspond to the 08 index.
Similarly, characters will correspond to index 25.
So there is no need for this data type.
We only need these two data types.
Right.
So let's do one thing, let's start implementing this, and then I will explain you step by step.
OK, so first start implementing this private sector.
Let's start writing the code.
OK, so as we have decided, first of all, we need to define what is an old so class trying, or you
can simply write a..
So let's simply write a note or you can write Prysner one and the same thing doesn't matter.
Just name and let's define some data members.
So for but as we have discussed is whether it is terminal or not.
So is terminal.
And second thing that we discussed is basically, uh.
We will have a. can have at most 26 children, so I was told point to my 26 children.
So my child, at the most I can have told the child this is very similar to the like we have implemented
trees, we have implemented by new trees.
This is very similar to that only.
And let's also have a constructor.
So in constructor, what we're going to do is so in constructor Istomin, let's set the value system
to be false.
So initially, no node is basically a terminal node and let's set the value for this for my child.
So initially, I don't have any of a child.
I have no child.
Since I have no child, I will.
Sternhell here point as I'm going to stonewall because currently I don't have a child.
So child of I will be storing them.
Simple, right?
OK, so this is our Todd, so what do we need here?
So I think we need two functions where two functions that we need we need a function and what this function
will do.
So it will contain it will take.
Which do you want to insert inside the tray?
Right.
This add function will take two things.
What is the word and in which tray you want to insert this word simple.
Right?
And the second function that we need will be search.
So in search it will take which what do you want to search and then which you want to search.
This one.
Simple, right.
So we need to write the definition for these two function, add and such.
So let's first write this add function.
We will add all the words of our dictionary in our tray.
So first, let us do that.
So let's create.
I try.
And this is our dictionary try or you can say it as rude, it's it's optional, right?
You can you can Delimiter Dictionary, our dictionary of Trie basically try your dictionary words or
you can simply write rude.
It doesn't matter.
So this is new Trenorden.
Sorry, you know.
OK, so the spelling of note will be Smolen or let's make it capitaland class A..
It's right, Naude hair and.
Let's right not here.
OK, so this is a..
So what is the impact of this line, what this line will do, it will create when node and this node
is terminal will be false.
So it's terminal is basically false.
And it has an area,
and since it has no child, so these all the pointers, all these pointers are basically starting.
OK, so this area, this area of 26 size is basically pointing towards.
Right, and this is my root node, so this is my root node.
Now I have my priority.
I have my priority.
I need to write the function and it will take word and try.
So this is my try.
OK, so let's start writing the code for their function.
So this area function will not return anything.
This ad function will take the world, which you want to insert, and it will take that right in which
you want to insert.
So let's name it right here.
Simple, so now, as we discussed, how do we insert the word?
It's very, very simple.
For example, if I want to insert A.R.T., so I have this root node.
So I want to insert Aadi, what I will do, I will I trade over this string, I will try to the string,
I will check whether it is pleasant or not.
So this is a is basically corresponding to the zero index.
It is pointing towards NUL, right.
It is pointing towards Nele.
So I will create one node and this null will basically point towards this node basically to make this
connection right.
And then you will come to this node and then you will come to this node.
So what we need to do, we need to irritate or whatever, so intense.
Verdant cites.
And what you need to do now is you need to get rid of this word so it equals zero, i.e. less than N.
I plumpness.
And here you here, first of all, we need to check whether L.A., which is touring, is present or
not.
So let's first check.
So if a child, child and the given character is basically void of IHI and the sensitises, uh, capital
E..
So I need to subtract capitally to get the value so it corresponds to zero.
So if this is basically null, that means the note does not exist.
So if the note does not exist, then you need to create one node.
So let's create the node.
So we need to create this node so there will be new, not simply.
And remember, after creating the world, after we have created the world, after we have created this
node, what we need to do, we need to go to this node, we need to go to this node.
So therefore, I will check this node.
Right.
We need to go to this node.
And how I will go to this not simply means I have made actually I have made this connection with the
help of this new node.
Now I want to go here.
I am standing here.
I want to go here.
So for doing that, what we need to do, we need to update our try and this will be tricolours.
Right off child of the given ward.
Minus.
And that's it.
So that's it, this our function book, so let me explain you from the starting.
See, what's happening here is I want to insert this area I am passing by.
So currently this is my train is terminal is basically false.
And I have this, Eddie, and this ad is them.
Ed, after the exercise, now the government is basically party, so I'm first finding out, like,
as we have discussed, what we need to do.
I need to I over this thing.
So I am I doing with this thing now I am checking for correctly.
So this is word of eye, which is character E, so E minus eight zero.
I told you I represent index zero.
Similarly Z present index 25.
So I am checking whether the child which is this.
So this is an all or not.
Yes.
This is null since the system then you will create a new node.
So create a new node.
And we are making the connection, so instead of Nele, it will store the address of this node.
So we have made this connection and after making the connection, as you remember, we have to come
to this node also.
I am standing here.
So this private label, I am standing at this node, but I want to reach additional because in the loop
next character will be out.
So I need to stand here and for standing here.
What I will do, I will.
This index will help us.
So now I am standing here.
Similarly for this not also new node will call the constructor and it will set the value of its terminal
to be false and its 26 size at every store.
All the values and all right.
All the value I stored.
And then now the next character is basically ah.
So I will check whether are essential or not.
So in this area I need to check.
Right.
Not in this area.
In this area.
I need to check.
That's why this code is important for standing here.
So I will check.
Yes it is.
And since it is null you will create a new node.
So you will create a new node with the help of this index.
And similarly, its terminal will be false because I will call the constructor and then it's during
this exercise area is going to stall.
And similarly, the are the index, I think.
I don't remember what will be the index of.
Ah, so you can subtract it and you will be able to find out the index and that index will store the
will point towards this node.
Similarly, you will be able to create one in order for E.
So for R.
Index, I think index is basically four or five, so if it is five, then at index five instead of starting,
then I will store the address to this node.
And finally, the last thing that we need to do is basically the last character is basically our terminal
character.
So we need to highlight this node.
We need to highlight this node and for highlighting this node we have a variable is terminal.
So initially that is terminal for this node is basically false.
We need to make through.
So after reaching after coming out of the after coming out of the vial, after coming out of this for
loop, I am standing here.
I am standing here.
So what I need to do instead of false, I need to make it true so that I can highlight that this is
a terminal node.
This is a terminal character.
So let's do the highlighting part.
So in highlighting part, what we need to do, we need to set the value.
So try arrow child.
Sorry, Triguero Estopinal.
Will be true and that.
And that's it.
So this air function will work, so that's it, guys, our air function will work properly and how you
will call the air function, it's very simple since we need to insert all the words in the dictionary.
So I will trade over the dictionary.
Dictionary says.
And for each word, for each word, what we need to do, we need to call this our function, so add
I get word of the dictionary and in which try and destroy root, even if this name is confusing you,
you can name it as a dictionary.
Also in dictionary try.
I am I am inserting a yet word.
So that's it.
So now your tribe is ready.
So our tribe is ready.
So how the tribe will look like again.
So this is the start node or basically the root node and then we will have a we will have ah we will
have East and Eastern Time in L.A. So this will be highlighted.
Similarly, I have said and this will this will be highlighted and similarly I have D then I have O
and all will be highlighted.
Similarly I have B here and this will be highlighted and similarly rest of the words.
So I will try is basically right now.
So I would add function is done now.
All we need to do, we need to write the code for search function.
So in next we do, we are going to write the code for the search function.
We will give one word and we will check whether the word is present in this trial or not.
Right.
So this is it from this device.
I will see you in the next one.
Thank you.