Download root parent child leaf node edge - TAMU Computer Science Faculty
Transcript
CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 263] Searching in a Trie To search in a trie: search(x,s): // x is node, s is string to search for -----------if length(s) = 0 then if x holds a complete key then return x else return null // s is not in the trie else c := first character in s if no outgoing edge from x is labeled with c then return null // s is not in the trie else x := child of x reached by edge labeled c s := result of removing first character from s search(x,s) endif endif Start the recursion with the root. To search for “art” and “bee”: a b l e n t e d e t