Загрузка...

Tries (Prefix Trees) | Tries (Prefix Trees) | Selection With Sathi

📚 Tries (Prefix Trees) | Tries (Prefix Trees)
Trie Structure, Insert, Search, Delete, Prefix Count & Autocomplete — with code & dry runs

📌 Key Formulas:
1. Trie Structure (Prefix Tree): Each node has up to 26 children (a-z); path from root = prefix
2. Trie Insert — O(L): Traverse/create nodes for each character; mark last as end
3. Trie Search — O(L): Traverse nodes for each character; check is_end at last node
4. Trie Delete — O(L): Unmark is_end; remove nodes if no other words share them
5. Prefix Count — O(L): Count words sharing a given prefix using prefix_count field

⏱️ Timestamps:
0:00 Introduction
0:30 Trie Structure (Prefix Tree)
1:17 Trie Insert — O(L)
2:05 Trie Search — O(L)
2:56 Trie Delete — O(L)
3:50 Prefix Count — O(L)
4:38 Insert Words Dry Run
5:29 Search 'car' Dry Run
6:11 Prefix Matching Dry Run
6:50 Delete 'car' Dry Run
7:38 Autocomplete Feature Dry Run
8:29 Quick Tips & Tricks | टिप्स
9:13 Summary | सारांश

💡 Quick Tips:
• Tries use more space than hash tables (one node per character) but give prefix-based queries for free
• Compressed trie (radix tree): merge single-child chains into one node to save space
• Applications: dictionary spell-check, autocomplete, IP routing tables, T9 predictive text
• GATE trie question: given n words of avg length L, insert time is O(n*L), space is O(SIGMA * N) where SIGMA=alphabet size, N=total nodes

📚 Useful for: GATE CSE, Placements, Coding Interviews and all govt exams

━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📱 Download App: https://play.google.com/store/apps/details?id=com.selectionwithsathi.app
🌐 Website: https://selectionsathi.com
🔔 Subscribe: https://www.youtube.com/@SelectionWithSathi

#SelectionWithSathi #Tries(PrefixTrees) #GovtExam #SSC #Railway #सरकारीपरीक्षा

Видео Tries (Prefix Trees) | Tries (Prefix Trees) | Selection With Sathi канала Selection With Sathi
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять