Тёмный

Data Structures: Tries 

HackerRank
Подписаться 266 тыс.
Просмотров 500 тыс.
50% 1

Learn the basics of tries. This video is a part of HackerRank's Cracking The Coding Interview Tutorial with Gayle Laakmann McDowell.
www.hackerrank.com/domains/tut...

Наука

Опубликовано:

 

26 сен 2016

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 162   
@xnadave
@xnadave 4 года назад
Another key phrase to keep in mind (asked during an interview a few years back): "Imagine that you're implementing autocomplete for a video search engine..."
@chineduenwere465
@chineduenwere465 3 года назад
exactly
@moisesacero4995
@moisesacero4995 4 года назад
'Hi, I'm Gayle Laakmann McDowell, author of Cracking the Coding Interview' was spoken as if she weren't a demi-god of the highest caliber.
@jay-rathod-01
@jay-rathod-01 3 года назад
😂 in all the videos. But honing a skill takes time. One day j will join the league of god's too.
@kumarmanish9046
@kumarmanish9046 2 года назад
@@jay-rathod-01 bhak
@millenialmusings8451
@millenialmusings8451 2 года назад
She’s overrated af
@vedkorla300
@vedkorla300 Год назад
@@kumarmanish9046 That's what a person with low self esteem and confidence says, when they can't best themselves they try to pull others down and scoff at them, you're just one of those people. Think and wallow in contemplation for a minute about what you wrote. You can never in your life achieve anything and you know it's the truth.
@apiphobian
@apiphobian 7 лет назад
5 mins to explain Trie is all you need if prepared! Perfect!
@davidlr97
@davidlr97 5 лет назад
"why don't you trie applying this to your own problems" ha...
@hozay6552
@hozay6552 3 года назад
Haha...
@Vlad.007
@Vlad.007 3 месяца назад
hahaha...
@muzammilnxs
@muzammilnxs 2 года назад
Quick notes, Motivation: String manipulation problems involves searching through a list of words/sentences. As a standard solution, we would store words in string or character array and iterate through characters to perform operations. This typically is limited by number of words in the list to search for and the number of characters that we have in the input string. If length of input string is l and number of words to search through is n, the time complexity would be O(l*n). For example, if there are 5 million words and length of input string is say 10, there would be 50 million operations which is extremely expensive computationally. Our goal is to reduce the time complexity to O(l) which is a factor of length of input string(l) only. So, for the above example, we would only have to do 10 operations to complete our search. • Generally, We would use a tree like data structure when we can arrange data in a hierarchical way using a property of the data. For example, BST exploits the nature of sorted numbers ie the parent number is greater/smaller than the children. For words in the dictionary, we can exploit the feature that most words have common root. e.g house, housemaid • The above nature of a tree data structure helps in massively reducing our search space for problems. • A binary tree implemented correctly reduces the time complexity from O(n) to O(log n). Internally, because of the way it is organized, every traversal reduces the search space by half. And that's how there is huge save in time • In binary tree, every node can lead to potentially two ways. In a Trie, every node can lead to potentially 26 ways(for character space lowercase alphabets a-z). Thus reducing our search space by a factor of 26 Potential character space allowed for a trie node is decided by the problem statement. Till now, we assumed the simple case of lower case alphabets(a-z). If we allow upper case alphabets(A-Z), then our search space increases to 52. And similarly we can decide to allow special characters, numbers and so on and so forth
@mailsiraj
@mailsiraj Год назад
beautiful explanation. thanks mohamed
@JoffreyB
@JoffreyB 7 месяцев назад
Not really, u didn't take into account that you need to build trie with 5 million words first, which takes n*m, where n is the number of words and m is the length of the longest word in that list.
@EchoVids2u
@EchoVids2u 3 года назад
I never learned about tries in data structures. This is the first time I have heard of them and I already graduated.
@ishaankulkarni49
@ishaankulkarni49 3 года назад
lol
@huanleminh6288
@huanleminh6288 3 года назад
My uni dont teach this data structure on the class, but they give me a project to build a mini search engine, then Trie is what i got recommend to put underlying the program
@brandonwilcox3307
@brandonwilcox3307 3 года назад
Same
@vighneshchavan8059
@vighneshchavan8059 2 года назад
Lol same
@selmankasmyurtaslan3923
@selmankasmyurtaslan3923 2 года назад
we are all same guys don't worry and "trie" to learn
@devendratapdia11
@devendratapdia11 7 лет назад
I love this blackboard, virtual board. Its real fun. If I would have had that same board while I was studying, what a fun it would have been
@Hitz9092
@Hitz9092 2 года назад
She is so down to earth…. Author of cracking the coding interview 🙏🙏
@vincenr8822
@vincenr8822 7 лет назад
Thank you so much for these videos.
@AninditKarmakar93
@AninditKarmakar93 4 года назад
A well articulated description in under five minutes to get me going with Trie data structures! Impressive!!
@PaulXiaofangLan
@PaulXiaofangLan 4 года назад
For UI engineer, this is the one we could use for autocomplete in combox or predict typo.
@jasonzhang2643
@jasonzhang2643 6 лет назад
What's the software that can make the virtual blackboard?
@lac2275
@lac2275 3 месяца назад
Fantastic condensed, down to the point explanation. Anybody with some CS background can easily fill in the holes of any left out details.
@sebbes333
@sebbes333 7 лет назад
THANKS! I have never heard about tries before.
@ognimoddd
@ognimoddd 4 года назад
You should TRIE to learn about it. okay I'll leave now
@MS-ib8xu
@MS-ib8xu Год назад
Great video! Very clear presentation and great examples.
@Bloodthirst
@Bloodthirst 3 года назад
i used this in my game engine where i divided the world into a bunch of cubes in 3D space , and instead of searching a word using characters (like the example of the video) , i pass the (x,y,z) of the cube and i get quick access to the object in that world chunck
@Mythricia1988
@Mythricia1988 5 лет назад
Huh, never heard of this before. I wonder if this would be handy for things like auto-complete mechanisms, or parsing partial commands and choosing the "closest" one, in an efficient way.
@user-jk4nu8sy7q
@user-jk4nu8sy7q 7 лет назад
Great tutorial, thank you very much!
@divyanksharma6075
@divyanksharma6075 7 лет назад
I have implemented this in my rest framwork url mapping.. its cool!!
@nands4410
@nands4410 6 лет назад
divyank sharma LINK!
@KushChoudhary
@KushChoudhary 4 года назад
@@nands4410 Did he gave?
@nands4410
@nands4410 4 года назад
@@KushChoudhary No he didn't. He is a chutiya
@KushChoudhary
@KushChoudhary 4 года назад
Nands 🤣 broo
@jay-rathod-01
@jay-rathod-01 3 года назад
Now this man is going to teach how to use tries data structure in XML file. He's the one who had NASA only using HTML without JS.
@WickedChild95
@WickedChild95 2 года назад
Very good explanation, thank you!
@KoreanLabx
@KoreanLabx 6 лет назад
May I know the book list stacked at the back???
@sathvikmalgikar2842
@sathvikmalgikar2842 Год назад
thanks for doing this hackerRank!! mind-blowing concept.
@Aerwith
@Aerwith 6 лет назад
What is this beautiful blackboard program?
@gabriellerosa6453
@gabriellerosa6453 4 года назад
paint
@Yotipo
@Yotipo 7 лет назад
thank you Ms McDowell
@AshutoshSingh007
@AshutoshSingh007 7 лет назад
Great series!!
@sahilrally4491
@sahilrally4491 4 года назад
Crisp and Clear, Cheers!
@christowndotcom
@christowndotcom 2 года назад
Ok explanation, but how do you store the state of current search? You mean just in a local variable or something?
@ojouniisama5401
@ojouniisama5401 4 года назад
Guys Im trying to implement a spellchecker program that loads a dictionary file with over 140k plus words with the longest word having 45 letters, correct me if I'm wrong if I use tries at most I would be using 46 * 26 = 116 bytes of memory right and this data structure would be more efficient compared to a hash table right... In C btw
@ctobi707
@ctobi707 6 лет назад
finite state machine comes to mind
@kellyzhang6012
@kellyzhang6012 4 года назад
We need a Non-deterministic Finite Automata (NFA) for the word validation problem, and clearly it would be more complex than implementing a trie. Because for this automata, we need to specify all transition functions (to next valid state or to a stop state). That means, one node will have at least 26 children in a corresponding trie.
@cokeeeeman1581
@cokeeeeman1581 6 лет назад
"The term trie was coined two years later by Edward Fredkin, who pronounces it /ˈtriː/ (as "tree"), after the middle syllable of retrieval" -- Wikipedia
@bareaye5897
@bareaye5897 5 лет назад
Tries were first described by René de la Briandais in 1959. The term trie was coined two years later by Edward Fredkin, who pronounces it /ˈtriː/ (as "tree"), after the middle syllable of retrieval. However, other authors pronounce it /ˈtraɪ/ (as "try"), in an attempt to distinguish it verbally from "tree". --Wikipedia
@MyFictionalChaos
@MyFictionalChaos 4 года назад
You pronounce it as "try" to distinguish it from other trees
@RobertPodosek
@RobertPodosek 2 года назад
What software are you using for this demo?
@mansigarg1760
@mansigarg1760 6 лет назад
Could you please share implementation of tries.
@susmitsircar
@susmitsircar 5 лет назад
basic implementation will be auto-complete feature during google search
@MyNameIsNotNick
@MyNameIsNotNick 6 лет назад
books in english, russian and korean about programming?
@KushChoudhary
@KushChoudhary 4 года назад
Keen Observer
@AK09037
@AK09037 3 года назад
And Spanish
@usanthosh007
@usanthosh007 6 лет назад
Nice video. I see a node's children are stored in hashmap. But where is the character of that node is stored?
@jappmayo1220
@jappmayo1220 6 лет назад
She seemed to not include it for some reason but yes you're right. There would be another field in that Node class that stores the actual value (character) for that given node.
@henz103
@henz103 2 года назад
Out of scope question, what type of tools used to make this video, I assume a Wacom tablet ? what about softwares ?
@brumarul7481
@brumarul7481 3 года назад
Determining DNA Health is hard , right?
@zhegemingzigouchang
@zhegemingzigouchang 6 лет назад
4:45 why don't you Trie applying this to a new problem...eh?
@AlgosExplained
@AlgosExplained 6 лет назад
I've watched a lot of these videos but I just noticed the korean book at the top of that stack
@surajk7091
@surajk7091 4 года назад
Same here :)
@denisr.8248
@denisr.8248 6 лет назад
Great VIDEO!
@Abdulmajeed-sy1us
@Abdulmajeed-sy1us 5 лет назад
If already "call" is inserted, if we next insert "all" , will it create a new branch from root? or it returns "all" is already present
@AbdAllahBoda
@AbdAllahBoda 5 лет назад
Well, I'd say that it will create a new branch from the root because it's a different prefix!
@ArturMusin
@ArturMusin 7 лет назад
Did you read that Russian book "Карьера Программиста" (Programmer's Career) which is right behind you?
@user-qr4rv3pi1j
@user-qr4rv3pi1j 6 лет назад
+Artur Musin, that's her Cracking Coding Interview book translated in Russian. lol. if("Карьера Программиста"=="Cracking Coding Interview"){return true;}
@techdose4u
@techdose4u 6 лет назад
hahaha :D These books r just for show :P
@Btotts
@Btotts 3 года назад
Really wish I would've seen this before my interview...
@scum3112
@scum3112 3 года назад
What did u say instead? Also what was the specific question? I’m gonna try and apply for internships soon and I wanna get a grasp of what kind of questions people get.
@DharminderSingh
@DharminderSingh 4 года назад
excellent video
@RajatSati
@RajatSati 7 лет назад
How does a trie deal wiith the collision? What if there is a duplicate key?
@randomizednamme
@randomizednamme 7 лет назад
You wouldn't really have duplicates with a trie ( or I guess you could say you have many). Let's say that you had a trie with the entire English dictionary as data. For each letter, there is a word that starts with that letter from a..z. So, the first level of your trie would have the letters a..z. While there are many words that start with 'a', they would all share the same 'a' node within the trie. So when you are adding a new word, you would check if a node for that letter has already been created, and if so move down the tree, if not, create that node.
@angelgodplace
@angelgodplace 2 года назад
@@randomizednamme Even if two words have the same spelling they show on the same dictionary entry. Besides there would be no way to distinguish them, unless you wanted to have ids for those words? Then you'd just create an extra level
@TheLoyalpain
@TheLoyalpain 4 года назад
We definitely didn't cover this in my college 0.0
@oliveredholm4284
@oliveredholm4284 7 лет назад
Excellent
@mba2ceo
@mba2ceo 2 года назад
How the F' does E have 3 links ?
@free-palestine000
@free-palestine000 3 года назад
why do interviewers ask this if we never went over it in school
@DaggerMan11
@DaggerMan11 3 года назад
because it's pretty easy to pick up if you already know about trees and hash maps, both of which are covered in school
@DoubleSwords117
@DoubleSwords117 Год назад
Was not expecting an Old Norse specialist Jackson Crawford shoutout, lol
@antonfernando8409
@antonfernando8409 2 года назад
Awesome, never heard of this sort of tree. One thing comes to mind immediately is recursion, if I am looking for all words starting with prefix 'Ca', then at the subtree under 'Ca', i feel you could make some recursive calls. please share your view on this, myself havent' done recursion since 2nd year CS class (back in 1991 lol).
@johnhammer8668
@johnhammer8668 7 лет назад
so it should not be balanced . right ?
@ClearerThanMud
@ClearerThanMud 7 лет назад
Right. You cannot balance a trie, because the position of a node encodes information -- if you were to move a node, you would necessarily change the data stored in the trie.
@haxpor
@haxpor 4 года назад
Perfect explanation.
@sps014
@sps014 6 лет назад
At 2:37 someone else noticed Chris Gayle (Cricket)
@suryasuresh9330
@suryasuresh9330 4 года назад
remember Chris Gayle's 175 in a T20 match, he's a beast
@gurumack
@gurumack 5 лет назад
gayle I love you. So much. That is all.
@Ishan555
@Ishan555 Год назад
The pun at the end haha
@vishalmishra1937
@vishalmishra1937 5 лет назад
thank u maam for explaining importance i was skippingtries for my exam .
@pranavpolakam5371
@pranavpolakam5371 4 года назад
The real question is... is a single instance of “tries” “try”, “trie”, or “tries”?
@memoriesadrift
@memoriesadrift 4 года назад
It's trie
@pranavpolakam5371
@pranavpolakam5371 4 года назад
@@memoriesadrift oh thanks
@JanacMeena
@JanacMeena 3 года назад
i trie to understand
@aidanzoldyk849
@aidanzoldyk849 6 лет назад
a korean book in the background? hmm interesting!
@IgorZimaev
@IgorZimaev 4 года назад
and Russian one: "Карьера программиста"
@rommelmartinez5599
@rommelmartinez5599 6 лет назад
This video should have been entitled “Data Structures: Tries in Java”.
@cimd00
@cimd00 5 лет назад
Her data structure implementation might have been in Java syntax, but it makes perfect sense in basically any other high level OOP language. Not sure how this is bound to Java as it's a pretty good high-level, language generic, explanation.
@victorriurean
@victorriurean Год назад
nice
@MrKB_SSJ2
@MrKB_SSJ2 Год назад
2:36 great example
@tombrady7390
@tombrady7390 3 года назад
wait how does she know about cricket I thought she was American
@wolfwalker_
@wolfwalker_ Год назад
Not to brag, I have two of those books.
@jay-rathod-01
@jay-rathod-01 3 года назад
Korean as well as Russian this woman is a linguist and a programmer.👍
@MoAdel92
@MoAdel92 3 месяца назад
spoiler alert you can use this video to under stand one-week-preparation-kit-no-prefix-set in hacker rank
@azuspace
@azuspace 3 года назад
If at first you don't succeed, try trie again.. :|
@Turnpost2552
@Turnpost2552 3 года назад
lol 0:30 what the hell did she say?????
@GoAheadShaun
@GoAheadShaun 3 года назад
"That node is really representing a word or a part of a word." By the way, readily-made subtitles are available.
@juan2thepaab
@juan2thepaab 3 года назад
her words are very hard to follow in this video
@Leon-pn6rb
@Leon-pn6rb 4 года назад
too fast explanation
@finally_code
@finally_code 2 года назад
This video helped me 0% in implementing this. Why not solve a demo problem with real code?
@Icix1
@Icix1 6 лет назад
"This isn't something CS students might have spent that much time in school, but it's really really important for interview" Translation: You'll never use this in the real world but employers love to make impractical problems part of their interview process. Can't have enough hoops to jump through, especially if it has nothing to do with the role you're hiring for!
@Icix1
@Icix1 6 лет назад
I graduated with a CS degree from a top tier school and now work for a big 4 company. Never used this in 10 years of actual work. It certainly has applications but pretty much irrelevant for 99% of CS grads. If you were to actually use it in the real world it wouldn't look like this anyways. It's good to know but silly to test for this for a SDE role.
@josephmorales652
@josephmorales652 6 лет назад
Its mostly used to weed out candidates for top tier companies. It sucks but its true. Want to work for the big 5? Learn to trie.... hehe
@josephmorales652
@josephmorales652 6 лет назад
oh and that's good to know you don't use it.
@philtrem
@philtrem 6 лет назад
@Jopdan proof ?
@MaxwellsWitch
@MaxwellsWitch 6 лет назад
I was actually looking for something like this...
@aakupsp
@aakupsp 7 лет назад
Sadly Khan doesn't win all Bollywood awards :p
@faraz584
@faraz584 5 лет назад
why are people saying "Thank you so much these are life savers". She jumps from different topics and doesn't even explain it. I have her voice speed toned down and still can't understand the work.
@errorgrisha
@errorgrisha 3 года назад
Карьера программиста? Книга на русском?
@vectoralphaSec
@vectoralphaSec 2 года назад
Not taught in schools yet really important for interviews? Yeah that s bullshit. That is whats wrong with jobs wanting people to know stuff that schools didnt even show them.
@romangavrilovich8453
@romangavrilovich8453 4 года назад
"Карьера программиста", кек
@osmankultur1943
@osmankultur1943 4 года назад
daymn :D
@c4pramod
@c4pramod Год назад
wired assent
@modata7a
@modata7a 2 года назад
a ramiiiiiiiiiiiiii
@jamessanchez9301
@jamessanchez9301 Год назад
4:44 Haha
@newtonpermetersquared
@newtonpermetersquared 2 года назад
🧢
@jojay6472
@jojay6472 5 лет назад
This bish detroyed the tech industry
@sinharakshit
@sinharakshit 5 лет назад
Lol wut? Why do you say that
@giancarloandrebravoabanto7091
@giancarloandrebravoabanto7091 3 года назад
So this is for spell check. Bahh boring and not useful for games
Далее
Trie Data Structure Implementation (LeetCode)
11:50
Просмотров 70 тыс.
Algorithms: Bit Manipulation
9:06
Просмотров 533 тыс.
Algorithms: Memoization and Dynamic Programming
11:17
Просмотров 964 тыс.
Data Structures: Heaps
10:32
Просмотров 1,2 млн
Implement Trie (Prefix Tree) - Leetcode 208
18:56
Просмотров 183 тыс.
Trie data structure - Inside code
13:26
Просмотров 9 тыс.
Tries
9:40
Просмотров 131 тыс.
What Is A Trie and How Do We Build One In Python?
18:24
Java Is Better Than Rust
42:14
Просмотров 152 тыс.
Suffix tries: introduction
26:27
Просмотров 8 тыс.