Trie Data Structure — Video Tutorial

Hi codechef community,

I have made a video on Trie Data Structure on my Youtube Channel. If you are new to this data structure, I hope this video helps you out.

If you found the videos helpful please do leave a LIKE on it!

6 Likes

Watch your this tutorial yesterday ,really a great one.
Brother can you share implementation code for trie or any problem along with solution where you have applied trie.
Thank you :blush:

Try this one

1 Like

To do this problem ,I want to learn trie implementation😅.
But Thank you :slightly_smiling_face:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

typedef struct node{
node *child[26];
ll ct;
node(){
ct=0;
for(ll i=0;i<26;i++) child[i]=NULL;
}
}node;

void build_Trie(string str,node *root){
string temp="";
ll n=str.size();
for(ll i=0;i<n;i++){
temp+=str[i];
temp+=str[n-i-1];
}
str=temp;
for(auto ch:str){
if(root->child[ch-‘a’]==NULL) root->child[ch-‘a’]=new node();
root=root->child[ch-‘a’];
root->ct++;
}
}
void solve(string *arr,ll n){
node *root=new node();
for(ll i=0;i<n;i++) build_Trie(arr[i],root);
}
This is the simple and smallest method to build a trie.try to understand and start with basic application of trie

1 Like

Brother ,Thank you so much :slightly_smiling_face: