11. Data Structures#
Choosing the right container for your data affects both correctness and performance. This chapter reviews core data structure concepts and shows how C#’s built-in collection classes implement them.
Why this chapter matters
The same data can be organized in many ways, each with different trade-offs:
sequential vs. key-based access patterns
insertion, deletion, and lookup costs vary by structure
stacks and queues model natural real-world orderings
understanding internals helps you reason about performance
Learning goals
By the end of this chapter, you should be able to:
compare the trade-offs of array, list, and dictionary in concrete scenarios
explain how a stack (LIFO) and queue (FIFO) differ
select an appropriate collection type for a given problem
trace through examples involving nested or composed data structures