Mid Collections

How does a SortedSet<T> differ from a HashSet<T>?

Feature SortedSet<T> HashSet<T>

Ordering Maintains sorted order No guaranteed order

Implementation Balanced binary search tree Hash table

Lookup

complexity

O(log n) O(1) average

Memory

overhead

Higher (tree nodes) Lower (hash buckets)

Use case When sorted data or range

queries needed

Fast insertion and lookup without

ordering

More from C# Programming Tutorial

All questions for this course