noob
noob

Reputation: 119

Data structure for reservation

Need a data Structure to store time based reservation on different resources. It should support below query:

  1. Latest reservation of a resource.
  2. For a given time, find all the reservations on all resources.
  3. ability to iterate on resource's next reservation

Upvotes: 0

Views: 409

Answers (1)

noob
noob

Reputation: 119

I am currently thinking of using List of reservation for each resource, and adding new reservation at the end of list.

  1. Latest reservation will be the last element of list [O(1)]
  2. For each resource, do a binary search on reservation list. [O(m*log(n) m-number of resource, n- size of reservation list ]
  3. Next element in list.

Interested in improving the time complexity for 2nd operation

Upvotes: 0

Related Questions