//This Java program demonstrates the implemntation of Trie Data structure in Java //This Implementation only supports lowercase letters class TrieNode{ TrieNode [] children= new TrieNode[26]; //Children a array of TrieNode pointers boolean isEnd; //a boolean variable used to indicate the end of the current word } class Trie{ TrieNode root; //Root of our Trie public Trie(){ root= new TrieNode(); //Intializing the root of our Trie } //This function insert the given word into our Trie public void insert(String word){ TrieNode curr= root;//get the root and create curr node to perform the operation for(int i=0; i "+isPresent); //Prints true as the word is exists boolean isStartsWith= t.startsWith("hack"); //Checks if any word starts with hack System.out.println("is there any word in our Trie that starts with hack => "+ isStartsWith); //Prints true boolean isPresent2= t.search("hecktoberFest"); System.out.println("is hecktoberfest present in our Trie => "+ isPresent2); //Printts false since there is no word with hecktoberfest t.delete("hacktoberfest"); //Delete the word from our Trie boolean isPresentAfterDeleting= t.search("hacktoberfest"); System.out.println("is hacktoberfest present in our Trie => "+ isPresentAfterDeleting); //Prints false as the word has been deleted } }