Citigroup Interview Question
Java DevelopersTeam: Risk Management/CMOT
Country: India
Interview Type: In-Person
What kind of lookups will be required? A directory is usually implemented using something like a B tree, but depending on your application, you may also go for self-balancing trees/treaps etc. If you're simply looking for an alternative to a dictionary, then you can consider using a trie, or hashing.
Use hashing and store the whole dictionary in a binary tree...
every word will create a unique hash code and based on code store and retrieve the meaning (stored in leaf element).
Ex: hash code for a: 00000, b:00001... n:01101, ... z: 11010
Hash code for word 'an': 0000001101
In the binary tree traverse left if its 0 and 1 for right.
Use Tree Data Structure
- Vaibhavs January 11, 2014