C# Binary Trees and Dictionaries

后端 未结 6 1051
悲哀的现实
悲哀的现实 2020-12-14 03:32

I\'m struggling with the concept of when to use binary search trees and when to use dictionaries.

In my application I did a little experiment which used the C5 libra

6条回答
  •  悲哀的现实
    2020-12-14 04:02

    The interface for a Tree and a Hash table (which I'm guessing is what your Dictionary is based one) should be very similar. Always revolving around keyed lookups.

    I had always thought a Dictionary was better for creating things once and then then doing lots of lookups on it. While a Tree was better if you were modifying it significantly. However, I don't know where I picked that idea up from.

    (Functional languages often use trees as the basis for they collections as you can re-use most of the tree if you make small modifications to it).

提交回复
热议问题