Data structure (C language version) concepts, data types, linear tables

Basic concepts of data structure (C language)

basic unit of data

The basic units of data are bits and bytes. Bit is the smallest unit of storage, which can represent a binary 0 or 1. A byte consists of 8 bits used to represent a character or number. In computers, commonly used data units include kilobytes (KB), megabytes (MB), gigabytes (GB), etc., which are 1024 bytes, 1024 kilobytes and 1024 megabytes respectively.

Data related definitions 

Data (data): All symbols that can be input into the computer, including numerical data and non-numeric data (text, characters, files, etc.)
Data element (data element): The basic unit of data, also called node (node) or record (record)
data item (data item): The smallest unit of data with independent meaning, also called domain (feild)
Data object (data object): a collection of data elements with the same characteristics
Data structure (data structure): exist among each other A collection of data elements of one or more relationships
 

logical structure of data 

The logical structure of data refers to the relationship between data elements, which describes the logical association and organization of data elements. Common data logical structures include the following:

1. Linear structure: There is a one-to-one relationship between data elements, that is, each data element has only one direct predecessor and one direct successor, forming a linear sequence. Common linear structures include linear tables, stacks, queues, etc.

2. Non-linear structure: There is a one-to-many or many-to-many relationship between data elements, that is, a data element may have multiple direct predecessors or direct successors. Common nonlinear structures include trees, graphs, etc.

3. Set structure: There is no specific order relationship between data elements. Each element is equal and independent of each other. Common collection structures include sets, hash tables, etc.

4. Sequential structure: There is a sequential relationship between data elements, that is, the order of data elements is fixed. Common sequential structures include arrays, linked lists, etc.

5. Nested structure: Data elements can contain other data elements to form hierarchical relationships or complex structures. Common nested structures include trees, graphs, etc.

Four basic structures:

(1) Set: There is no other relationship between the data elements in the structure other than the relationship of "belonging to the same set"; (2
) Linear structure: There is a one-to-one relationship between the data elements in the structure;
(3) ) Tree structure: There is a one-to-many relationship between the data elements in the structure;
(4) Graph structure or network structure: There is a many-to-many relationship between the data elements in the structure.

These logical structures can be flexibly combined and applied in practical applications to meet different data processing needs.

Data storage structure 

Data storage structure refers to the way in which data is stored and organized in a computer system. Common data storage structures include the following:

1. Array: It is a linear structure that stores data of the same type in a continuous memory space in order. Elements in an array can be quickly accessed by index value.

2. Linked List: It is also a linear structure, but the elements are not necessarily stored continuously. Each element contains data and a pointer to the next element, which can be traversed and accessed.

3. Stack: It is a special linear structure that adopts the last-in-first-out (LIFO) principle. Insertion and deletion operations can only be performed on the top of the stack, similar to a stack of plates.

4. Queue: It is also a linear structure, using the first-in-first-out (FIFO) principle. Elements can only be inserted at the end of the queue and deleted at the beginning, similar to waiting in line.

5. Tree: It is a non-linear structure composed of nodes and edges. Each node can have multiple sub-nodes, forming a hierarchical relationship. Common tree structures include binary trees, binary search trees, etc.

6. Graph: It is also a non-linear structure consisting of nodes and edges. The relationship between nodes can be arbitrary and is often used to represent complex structures such as networks and social relationships.

7. Hash Table: Use a hash function to map data into a fixed-size array, allowing for fast insertion, search, and deletion operations. Suitable for situations where quick search is required.

The above are only common data storage structures. In actual applications, other more complex data structures may be used to meet specific needs.

According to the different characteristics of values, data types in high-level languages 

Data types in high-level languages ​​can be divided into several different types based on their characteristics, including:

1. Basic data types: These types include integers, floating point numbers, characters, and Boolean values. Basic data types occupy a fixed space in memory and have specific value ranges and operation rules.

2. Composite data types: These types include arrays, structures, and enumerations. An array is a collection of elements of the same type, a structure is a collection of data members of different types, and an enumeration is a discrete set of named constants.

3. Reference data types: These types include pointers and references. Pointers are variables that store memory addresses and can be used to indirectly access other variables or data structures. A reference is an alias for an existing variable, which allows direct access to the original variable.

4. Abstract data types: These types include classes, interfaces, and modules. A class is a user-defined type that encapsulates data and related operations, an interface defines a set of behavioral specifications, and a module is a collection of related functions.

Each data type has its specific uses and limitations in programming, and developers can choose the appropriate data type to store and manipulate data based on actual needs.

Algorithms and algorithm analysis 

Characteristics of the algorithm:

  • Input: 0 or more inputs
  • Output: There are one or more outputs
  • Certainty: Every step is certain and unambiguous
  • Finiteness: the algorithm should end after a finite number of steps
  • Feasibility: Every operation can be executed

Requirements for designing algorithms:

  1. correctness
  2. readability
  3. Robustness
  4. Efficiency (time cost and space cost)

 

 

 

 

 

Guess you like

Origin blog.csdn.net/Z_CH8648/article/details/132765252