A data structure!
- Define "data structure."
- Distinguish between data type and data structure.
We've established that based on the specification of a problem, we choose whether find
implements the linear or binary search. That choice would require organizing the (students
array) data in different ways (sorted vs. unsorted). To establish the desired organization of data, we would have to implement add
and remove
methods differently.
There are many cases where efficiently solving a problem requires such due diligence in the organization of data and implementation of operations that manipulate the data, just as in the Roster
class.
A Data Structure encapsulates organized mechanisms for efficiently storing, accessing & manipulating data.
Thus Roster
is indeed a data structure.
In the general sense, any data type (even as simple as an integer) can be viewed as a simple data structure. More commonly, a distinction is made so the term "data structure" means an organization or structuring for a collection of data types.
Don't fixate too much on what is a type and what is a structure; in future chapters, we will make a clear distinction by using Java Interfaces to define (abstract) data types. Data structures would be fully specified, non-abstract (concrete) classes that implement those interfaces.
Resources
- CrashCourse has a fun video on Data Structures; a bird's-eye overview of many of the data structures we will be looking at in this course.