I'm sure many of you should have taken a Data Structures and Algorithms class, and these two concepts are often discussed together as if they were twins. So what exactly is their relationship like?
When I heard about data structures and algorithms, my first thought was that Nicholas Wirth, the father of the Pascal language, made the famous observation in computer science [Programs = Algorithms + Data Structures = Programs] in his book Algorithms + Data Structures = Programs.
From this point of view, data structures and algorithms should be two completely independent disciplines, but most of our usual contact with the two at the same time to talk about, the feeling that the two are one and the same, in order to figure out what is the relationship between the two specific, we need to first understand what they are each.
Here's a definition of the two from one of the sections I've excerpted:
data structureIt is a format for data organization, management and storage. Data structure studies the logical and physical structure of data and the relationship between the two.
arithmeticIt is an accurate and complete description of a solution, a series of clear instructions for solving a problem, and an algorithm represents a systematic approach to describing a strategic mechanism for solving a problem.
From the definition alone may be difficult to directly see the relationship between the two, we put the two together an important basis also comes precisely from the famous point of view [program = algorithm + data structure], because we usually pay more attention to the program is to solve practical problems. At this point it is also necessary to algorithms and data structures complement each other to solve problems together.
An algorithm is a solution to a problem, a set of instructions, which then means that it must beimportationI don't know what to say.importationIn order to know the problem to be solved, in order to manipulate the instructions, what is the input? That's it.digital。
Data structures are the key to managingdigitalof organization and storage is the study of data.
So for us to link data structures to algorithms, we need to build a bridge, and thisdigitalIt's just the best choice, or call it:data type。
Data types are the cornerstones of algorithms, they serve algorithms, and algorithms are built on top of specific data types.
The data type is the soul of the data structure, data definition, organization, storage and finally for the application, data type is the last step of sublimation, so that the static data has a meaning.
Secondly, data structure focuses on three elements: logical structure, physical structure, and data operations. Logical structure refers to the logical relationship between the data and the data ultimately stored in the computer has no relationship to the actual location, while the physical structure refers to the data ultimately exists on the computer location, and finally the data operation is for the logical structure of the operation.
The above said data type is equivalent to the logical structure of the data structure + data operations, most high-level language programmers are not too concerned about the final storage location of the data, because the high-level language has been done for us, which also leads to a lot of times our default data structure is the data type, mentioned the data structure is the definition of the class how to mention the solution to this problem is the need for what algorithm, algorithm What data types are needed to support, over time, we are accustomed to the data type as a data structure, also accustomed to the data structure and algorithm bound together.
Data structures and algorithms are both closely related to each other and have their own concerns, so we still need to figure out the relationship between them. Also for our later in-depth study of data structures and algorithms to provide an intuitive feeling.
classifier for sums of money: The test method code as well as the example source code have been uploaded to the codebase for those who are interested. /hugogoos/Planner