troubleshooting Question

Evaluating data strutures

Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland asked on
C#Microsoft Visual Studio
2 Comments1 Solution96 ViewsLast Modified:
I'm using C# in Visual Studio 2017.  I came across this page outlining the performance of different data structures.
Is there an article giving use cases for each structure?  At the moment I'm just interested in common structures like arrays, lists, dictionaries, stacks and queues.
Apart from inserting, updating, deleting and viewing records, what criteria are used when evaluating different data structures for a given project?

I saw this online which partially answers my question.  If space is not an issue when would I use a list as opposed to a dictionary?
When should I use something non standard like binary trees?

The SortedDictionary<TKey, TValue> generic class is a binary search tree with O(log n) retrieval, where n is the number of elements in the dictionary. In this respect, it is similar to the SortedList<TKey, TValue> generic class. The two classes have similar object models, and both have O(log n) retrieval. Where the two classes differ is in memory use and speed of insertion and removal:

SortedList<TKey, TValue> uses less memory than  SortedDictionary<TKey, TValue>.

SortedDictionary<TKey, TValue> has faster insertion and removal operations for unsorted data: O(log n) as opposed to O(n) for  SortedList<TKey, TValue>.

If the list is populated all at once from sorted data,  SortedList<TKey, TValue> is faster than SortedDictionary<TKey, TValue>.
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros