dev/bst_tries_02.cpp
void TrieInsert(struct TrieNode *root, string key) 
{ 
	struct TrieNode *pCrawl = root; 

	for (int i = 0; i < key.length(); i++) 
	{ 
		int index = key[i] - 'a'; 
		if(!TreeSearch((node *)pCrawl->root,index))
			pCrawl->root = TreeInsert((node *)pCrawl->root,index,getNode(index));
		
		pCrawl->descendents+=1;
		pCrawl = TreeSearch((node *)pCrawl->root,index)->address;

	} 

	// mark last node as leaf 
	pCrawl->isEndOfWord = true; 
}
// If not present, inserts key into trie 
// If the key is prefix of trie node, just 
// marks leaf node 
If not present, inserts key into trie
If the key is prefix of trie node, just
marks leaf node
If not present inserts key into trie If the key is prefix of trie node just marks leaf node
void TrieInsert(struct TrieNode *root, string key) 
{ 
	struct TrieNode *pCrawl = root; 
	for (int i = 0; i < key.length(); i++) 
	{ 
		int index = key[i] - 'a'; 
		if(!TreeSearch((node *)pCrawl->root,index))
			pCrawl->root = TreeInsert((node *)pCrawl->root,index,getNode(index));
		pCrawl->descendents+=1;
		pCrawl = TreeSearch((node *)pCrawl->root,index)->address;
	} 
	pCrawl->isEndOfWord = true; 
}
void TrieInsert ( struct TrieNode * root , string key ) { struct TrieNode * pCrawl = root ; for ( int i = 0 ; i < key . length ( ) ; i ++ ) { int index = key [ i ] - ' ' ; if ( ! TreeSearch ( ( node * ) pCrawl -> root , index ) ) pCrawl -> root = TreeInsert ( ( node * ) pCrawl -> root , index , getNode ( index ) ) ; pCrawl -> descendents += 1 ; pCrawl = TreeSearch ( ( node * ) pCrawl -> root , index ) -> address ; } pCrawl -> isEndOfWord = true ; }
If not present, inserts key into trie
If the key is prefix of trie node, just
marks leaf node
If not present inserts key into trie If the key is prefix of trie node just marks leaf node
// mark last node as leaf 