1 / 6

Tries

Tries. Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University. Intro to Tries. An efficient data structure for dictionary (which uses strings as keys) English dictionary (from a given word to its definition) Yellow page (from a given name to his/her phone number)

Download Presentation

Tries

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tries Jyh-Shing Roger Jang (張智星) CSIE Dept, National Taiwan University

  2. Intro to Tries • An efficient data structure for dictionary (which uses strings as keys) • English dictionary (from a given word to its definition) • Yellow page (from a given name to his/her phone number) • Why you need to learn tries • An alternative solution to <map> and <unordered_map> • For job interviews • For our homework

  3. ANIMATION OF TRIES Quiz! • Construction • key = the, a, there, answer, any, by, bye, their • Search • any • these

  4. Code Examples • Examples • trie00.cpp  C-flavored • trie01.cpp  C++

  5. Complexity • Assuming we have n keys, each with m characters • Tries • Time complexity • Construction: O(m*n) • Search/insert: O(m) • Space complexity: O(ALPHABET_SIZE*m*n)=O(m*n) • Binary search • Time complexity • Construction: O(m*n*log(n)) • Search: O(m*log(n)) • Space complexity: O(m*n) Quiz! 26 for English

  6. References • References to tries • Video • HackerRank • Trie data structure (with detailed example) • CS50: Kevin Schmid , Details • Trie: Insert and search (with code) • Programming tutorials by SourceTrick (with code) • CS50: slides Course from Harvard Univ.

More Related