“This article has participated in the good article call order activity, click to see: back end, big front end double track submission, 20,000 yuan prize pool for you to challenge!”

What is a data structure

Data structure = Data + structure

Data is an abstract concept that can be classified into basic types in a programming language, such as int, float, and so on. These data may have the relationship between including and being included, and may have the relationship between before and after, etc., which can be abstracted as structure.

The difference between algorithms and data structures

  • Data structures represent relationships between static data elements

  • An algorithm describes specific steps to solve a problem

  • Program = data structure + algorithm

  • Summary: Algorithm is an operation procedure designed to solve problems, and data structure is the carrier of algorithm to deal with problems

Order table and order structure

The sequential structure is the simplest data storage structure.

The storage of table elements one by one into a group of contiguous storage cells, this storage structure is the order structure.

Linear tables with sequential storage structures are often called sequential tables. Sequential table is to store the nodes in the table in sequence in a group of memory units with contiguous addresses in computer memory.

As long as the starting position of the order table is determined, the address of any element in the table can be found by the following formula:

LOC(ai) = LOC(A0) + I *L, L is the length of the storage unit occupied by the element, I >=1, which can be shown in the following figure. Suppose we have another list L = [A, B, C, d] and store it in a sequential structure. When we select L[2] directly, the data c stored in the physical location L0 +2*L is directly accessed internally.

Logical addresses The element Physical address
0 a l0
1 b l0+1*L
2 c l0+2*L
3 d l0+3*L