Dictionary best data structure for train routes?

后端 未结 6 1153
北海茫月
北海茫月 2020-12-02 01:08

So I\'ve been tasked with essentially reading in a file (notepad file) that has a bunch of train stops and the time it takes to get from one stop to another. For example it

6条回答
  •  失恋的感觉
    2020-12-02 01:29

    A Dictionary is a set of values stored by the hashes of a set keys. The advantage of using a dictionary is the time needed to locate a specific record regardless of size is fixed (often called O(1)). Alternatively if you used a list, the time needed to locate a record would be equal to the time it takes to read each element (often called O(n) where n equals the number of elements in the list).

提交回复
热议问题