router
router

Reputation: 7

Data structure recommendations

I am trying to make a data structure in which a single contact can be stored as “First Name”, “Last Name” and “phone number” in alphabetical order. With the passage of time phone book updates as new contact comes or removed from the phone book.
Following are two factors which must keep in mind while performing the required task.

If I use hash table, inspite of being fast enough, it would take a lot of space.
So what data structure should I use if there is space limitation of 2 GB?

Upvotes: 0

Views: 116

Answers (1)

Anmol Singh Jaggi
Anmol Singh Jaggi

Reputation: 8576

As suggested in the comments, if there is a hard limit of 2 GB, it essentially means that a data structure of constant space complexity is required.
Unfortunately, no such data structure exists.

On the other hand, a Self-balancing binary search tree is a very good data structure in terms of the tradeoff between time and space complexity.

Check out this link for the time and space complexities of various other data structures.

Upvotes: 1

Related Questions