Data structure to handle the requirement of following use case

前端 未结 5 1736
梦谈多话
梦谈多话 2021-01-29 13:10

All the records in a database is saved in (key, value) pair formats.Records can always be retrieved by specifying key value. Data structure needs to be developed to handle follo

5条回答
  •  春和景丽
    2021-01-29 13:51

    A dictionary (hash map, etc.) would easily handle those requirements, although your third requirement would be an O(N) operation. You just iterate over the keys and select those that match your criteria. You don't say what your desired performance is for that case.

    But O(N) might be plenty fast enough. How many items are in your data set, and how often will you be performing that third function?

提交回复
热议问题