This problem is troubling me from so long time.
There are N scientists, K black holes, and any scientist can query about radius, size and temperature of any blackhole.

You have to answer three kinds of query basically:

1)Given Scientist queried for which blackholes,Given scientist queried for which attributes
2) Given blackhole, who all scientist had quaried on it, which attributes of it had been queried upon
3) Given attribute which scientist has queried upon it and which blackhole has it been queried upon
All should be in O(1) time complexity.

Which data structure will you use for this?

Recommended Answers

All 2 Replies

Sounds like a school exercise. How long have you been working on this?

@rubberman, :p I am not a school guy now. :) I thought of hashmaps. I don't know how to use them in this case as I want O(1), so hashmap is the good way but dont know how to use them. If you can help anyway, that would be good. Actually, somebody asked me this question long back but now I want how to solve this one.

I dont want any code or like that. I want algorithm or some hints or some source where I can start from.

P.S In my school, college, even company they dont expect me to solve this type of problems. :-D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.