The Big O of Distinct() method with a Custom IEqua

2019-06-26 03:54发布

Anyone knows the Big O of the algorithm used in the Distinct() method, with a custom IEqualityComparer?

标签: c# linq big-o
1条回答
老娘就宠你
2楼-- · 2019-06-26 04:13

There's an equal question here on SO about "What guarantees are there on the run-time complexity (Big-O) of LINQ methods?"

See this section in the answer about distinct:

Distinct, GroupBy Join, and I believe also the set-aggregation methods (Union, Intersect and Except) use hashing, so they should be close to O(N) instead of O(N²).

查看更多
登录 后发表回答