What is a data structure?
A data structure organizes the data used by a program to efficiently solve a problem or respond to queries. Different data structures exist to support the implementation of a broad variety of algorithms. The choice of a data structure depends on what type of problem is being solved and how the data is represented. It is important to note that a data structure is a programming construct. It is not necessarily a physical component of the computer nor an organized information management tool such as a database. Instead, most data structures are built on the concept of variables and are a formally organized way of managing the information used in a computer program.
Most students have little difficulty picturing a transition from storing one piece of information in a variable to storing multiple related things in a data structure. If a variable is used to store a student’s test score from a recent exam, it seems reasonable to want to store an entire set of students’ scores on that exam. Alternately, we may want to maintain the set of a single student’s test scores from an entire semester. These individual values could all be stored using unique variables, but this presents problems for a programmer.
Common data structures used in a wide range of algorithms include strings, lists, arrays, stacks, queues, linked lists, dictionaries, sets, trees, and graphs. Some data structures are “native” to a programming language and using them involves little effort. For others, the programmer needs to provide an implementation.
Data structure material covered: