⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trie.h

📁 这是清华出的这本经典的数据结构第三版上的随书例子。希望对大家有用。
💻 H
字号:
//************************  trie.h  *********************************class Trie;class TrieNonLeafNode {public:    TrieNonLeafNode() {    }    TrieNonLeafNode(char);private:    bool leaf, endOfWord;    char *letters;    TrieNonLeafNode **ptrs;    friend class Trie;};class TrieLeafNode {public:    TrieLeafNode() {    }    TrieLeafNode(char*);private:    bool leaf;    char *word;    friend class Trie;};class Trie {public:    Trie() : notFound(-1) {    }    Trie(char*);    void printTrie() {        *prefix = '\0';        printTrie(0,root,prefix);    }    void insert(char*);    bool wordFound(char*);private:    TrieNonLeafNode *root;    const int notFound;    char prefix[80];    int  position(TrieNonLeafNode*,char);    void addCell(char,TrieNonLeafNode*,int);    void createLeaf(char,char*,TrieNonLeafNode*);    void printTrie(int,TrieNonLeafNode*,char*);};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -