Bloomberg LP Interview Question
Software Engineer / DevelopersInterviewer> Assume we have a million records with Name, Address, Ph No.. which data structure would we use for storing?
My Answere> Initially i said Linked List and he asked me what would be the time complexity if need to search an element.... i said best case O(1) and worst case would be O(n)... i said i would use Hash Table since it's quicker than linked list.
Interviewer> What's the time complexity of HashTable?
My Answere> O(1)
Interviewer> Assume we have to use HashTable, and we need to search with Name, how would we know what's the key value? So we need to search for the key itself, then would'nt the Time Complexity would be O(n) again? So then what's the difference between linked list and hashtable?
My Answere> ??
The difference b/w a linked list and hashtable is the user's perspective. Hashtable is O(1) because a hash function takes care of the mapping from key to value. Linked list is O(n) because of the traversal left/right. The user never searches for the key itself directly. That's not abstraction and an internal data structure is abstracted for user flexibility. This gets into why OO is so useful.
External events are asynchronous and should to be handled in a new thread fto allow original thread to run to completion.
- Jack April 18, 2006Delegates mirror delegation in Java. Java handles most events with a thread.