in the first video on tries it is given that we prefer to build a hashmap instead of a trie when we have about 1000 contacts in phonebook and trie for much larger contacts.in the second and third video the space complexity for both hash maps and tries is analysed.clearly from that the space complexity of trie is lesser than hashmap .so why do not we use trie even for 1000 contacts.in the video it is said that for about 1000 contacts trie will take much more space.how ?please justify it.
Confusion in the trade off between hash map and trie
@Rj.25
So what happens is you can assume each number is 10 digits long
Now in a trie each node holds a pointer array of size 10
But in case of hashmap strings will take exactly as much space as count of strings in it
Eg -
Let’s say input is 234 and 345
Input number are 3 digit long
In hashmap space taken will be approx 6*(int)
While in trie there are 6 digits each with its own node holding an array of pointer of size 10
So space taken becomes approx 60*(int)
Trie becomes advantageous when input numbers are too many since at that point you end up reusing many nodes in the trie so no extra space is taken while hashmap increases size by input size after each input
If your doubt is resolved please close it
thanku sir very nicely explained