Introduction
Data Structure
Introduction
Data
Define: The set of all the symbols can be processed or stored by a computer Example: A data set in a classroom = { desk 1, desk 2,…chair 1, chair2…,stud 1, stud 2,…}
Data Element
Define: The term data element is an atomic unit of data that has:
- An identification such as a data element name
- A clear data element definition
Example: desk i; chair j; project n…
Data item
Define: One smallest indivisible data units
!!! One data element consists of one or many data items.
Data Object
Define: The collection of data elements with same features.
Example: Data Object 1: ={ desk 1, desk 2,…};
Data Object 2: ={ chair 1, chair 2,…};
Data Object 3: ={ stud 1, stud 2,…};
On Data Object3, The data of a student is a set of {ID, FirstName, LastName, age}, in a list of student, the list of age = {12, 13, 12, …}, then ->
Data Element:age
Data item: 12
Structure
Relationships between data elements
Data Structure
A set of data elements with structure
Data Structure can be defined is math
Data Structure = (D, R)
D: the set of Data elements
R: the Relationships of the data elements
DS is formed by two sets:
- Data element set
- Relationship set
Class of Structure
- logic structure -> {Set, Linear, Tree, Graph}
- Physical structure -> Such as a Linear structure use sequence structure or Linked structure ?
About algorithm
- Algorithm design depends on logical structure(Like in math)
- Algorithm implementation depends on how to store the DS physical structure
Data Type
Define: A data type is a collection of objects and a set of operations that act on those objects.
Example:int, double … and std::vector<>, std::map<> …
Abstract Data Type (ADT)
Define:An abstract data type(ADT) is a data type that is organized in such a way that the specification of the objects and the operations on the objects is separated from the representation of the objects and the implementation of the operations.
Conclusion: Consider only the mathematical level, not the actual computer structure
Mathematical definition of ADT:
- D:Data object , the set of the data elements
- S:the structure on the object D
- P:Operations performed on the object
Example:
|
|
Kind of parameters
- Value parameter
- Reference parameter (in c++ is &)
Summary
- DS = Data elements + Relationships of data elements
- Data structures + Algorithms = Program
- ADT = DS + Operations