61B-37:overview, Tries HHZZ included in UCB-CS61B 2024-07-11 102 words One minute Contents Overview Tries——前缀树/字典树 implementation T9 keyboard Ternary search Tries Overview Tries——前缀树/字典树 usages: prefix matching approximate matching 1 2 keysWithPrefix(String prefix) // returns all keys in the trie that start with the given prefix longestPrefixOf(String query) // returns the longest key in the trie that is a prefix of the query implementation 1 2 3 4 5 6 7 8 private class Node{ boolean exists; Map<Character, Node> links; public Node(){ links = new TreeMap<>(); exists = false; } } T9 keyboard Ternary search Tries 1 2 3 4 5 6 7 public class TSTSet<Value>{ private Node<Value> root; private static class Node<Value>{ private char c; private Node<Value> lo, mid, hi; } } 但是这种实现方式表现不佳