| 1 | Insert 'cat' | {} | node points to root | {} |
| 2 | Insert 'c' | {} | node = root['c'] created | {'c': {}} |
| 3 | Insert 'a' | {'c': {}} | node = node['a'] created | {'c': {'a': {}}} |
| 4 | Insert 't' | {'c': {'a': {}}} | node = node['t'] created | {'c': {'a': {'t': {}}}} |
| 5 | Mark end of 'cat' | {'c': {'a': {'t': {}}}} | node['$'] = True | {'c': {'a': {'t': {'$': True}}}} |
| 6 | Insert 'car' | {'c': {'a': {'t': {'$': True}}}} | node = root['c'] | {'c': {'a': {'t': {'$': True}}}} |
| 7 | Insert 'a' (exists) | {'c': {'a': {'t': {'$': True}}}} | node = node['a'] | {'c': {'a': {'t': {'$': True}}}} |
| 8 | Insert 'r' | {'c': {'a': {'t': {'$': True}}}} | node['r'] created | {'c': {'a': {'t': {'$': True}, 'r': {}}}} |
| 9 | Mark end of 'car' | {'c': {'a': {'t': {'$': True}, 'r': {}}}} | node['$'] = True | {'c': {'a': {'t': {'$': True}, 'r': {'$': True}}}} |
| 10 | Insert 'dog' | {'c': {'a': {'t': {'$': True}, 'r': {'$': True}}}} | node = root['d'] created | {'c': {'a': {'t': {'$': True}, 'r': {'$': True}}}, 'd': {}} |
| 11 | Insert 'o' | {'c': {'a': {'t': {'$': True}, 'r': {'$': True}}}, 'd': {}} | node = node['o'] created | {'c': {'a': {'t': {'$': True}, 'r': {'$': True}}}, 'd': {'o': {}}} |
| 12 | Insert 'g' | {'c': {'a': {'t': {'$': True}, 'r': {'$': True}}}, 'd': {'o': {}}} | node = node['g'] created | {'c': {'a': {'t': {'$': True}, 'r': {'$': True}}}, 'd': {'o': {'g': {}}}} |
| 13 | Mark end of 'dog' | {'c': {'a': {'t': {'$': True}, 'r': {'$': True}}}, 'd': {'o': {'g': {}}}} | node['$'] = True | {'c': {'a': {'t': {'$': True}, 'r': {'$': True}}}, 'd': {'o': {'g': {'$': True}}}} |
| 14 | Search prefix 'ca' | {...} | node = root['c'] | {'c': {...}} |
| 15 | Traverse 'a' | {...} | node = node['a'] | {'a': {...}} |
| 16 | Prefix found, collect words | {...} | Traverse subtree from node | Words: ['cat', 'car'] |
| 17 | Hash Map store words | Hash Map keys: ['cat', 'car', 'dog'] | Store full words as keys | {'cat': True, 'car': True, 'dog': True} |
| 18 | Search prefix 'ca' in Hash Map | Hash Map keys | Check keys starting with 'ca' | Matches: ['cat', 'car'] |
| 19 | End | Final Trie and Hash Map states | No pointer changes | Trie and Hash Map ready for prefix queries |