🔨 TRIE BUILDER: INSERT MODE

Word Queue

Current Word

Code Execution

void insert(String word) {
  Node temp = root;
  for(char ch : word) {
    if(!temp.map.containsKey(ch)) {
      temp.map.put(ch, new Node());
    }
    temp = temp.map.get(ch);
  }
  temp.eow = true;
}

Controls

Status

🎯 PREFIX HUNTER

Dictionary

Enter Prefix

Code Execution

int countPrefix(String prefix) {
  Node temp = root;
  for(char ch : prefix) {
    if(!temp.map.containsKey(ch))
      return 0;
    temp = temp.map.get(ch);
  }
  return temp.count;
}

Test Cases

Result

⚡ AUTO-COMPLETE MASTER

Dictionary

Type to Search

Applications

📝 Spelling Checker
📱 Phone Book
🔍 Search Suggestions
💻 IDE Autocomplete

DFS Traversal

🔬 TRIE NODE VISUALIZER

Node Structure

class Node {
  boolean eow;
  HashMap<Character, Node> map;
  int count;
}

Add Word

Words in Trie

Selected Node Info

Click on a node to view details

Controls

📊 WORD OCCURRENCE FINDER

Dictionary

Find Prefix Occurrences

Code Execution

// Insert with count
void insert(String word) {
  Node temp = root;
  for(char ch : word) {
    if(!temp.map.containsKey(ch))
      temp.map.put(ch, new Node());
    temp = temp.map.get(ch);
    temp.count++;
  }
  temp.eow = true;
}

// Get count
int getCount(String prefix) {
  Node temp = root;
  for(char ch : prefix) {
    if(!temp.map.containsKey(ch))
      return 0;
    temp = temp.map.get(ch);
  }
  return temp.count;
}

Test Cases

Result