One of the PHP Data Structures: basic concepts of PHP Data Structures-data structures

Source: Internet
Author: User
To learn any technology, you must first understand its basic concepts. this is the starting point for learning any knowledge! This article describes the basic concepts of data structures. it is suitable for programmers who already have a certain degree of Foundation for data structures and for code users who want to learn data structures! Let's start the PHP Data Structure Chapter.

To learn any technology, you must first understand its basic concepts. this is the starting point for learning any knowledge! This article describes the basic concepts of data structures. it is suitable for programmers who already have a certain degree of Foundation for data structures and for code users who want to learn data structures! Let's start the PHP Data structure chapter!

I. Basic concepts

(1) general process of compiling a program to solve the actual problem:

1. how to describe the problem in the form of data, which abstracts the problem into a mathematical model;

2. the data volume involved in the problem and the relationship between the data;

3. how to store data in a computer and reflect the relationship between data;

4. operations performed on data during data processing;

5. check whether the program has good performance.

(2) Data ):

It is a symbolic representation of objective things. in computer science, it refers to all symbols that can be input into a computer and processed by computer programs.

(3) Data Element: it is the basic unit of Data. it is usually considered and processed as a whole in a program. A Data element can be composed of several Data items. Data items are the smallest units that are inseparable from each other. A data item is a description of a certain aspect of an objective object.

(4) Data Object: a collection of identical Data elements and a subset of Data. Such as character set C = {'a', 'B', 'c ,...} .

(5) data structure: a collection of data elements that are related to each other.

(6) logical structure of data: the relationship between data elements is called logical structure.

(7) There are four basic types of data logical structure:

1. set: there is no other relationship between data elements in the structure except "belong to the same set;

2. linear structure: the data elements in the structure have a one-to-one relationship;

3. tree structure: there is a one-to-many relationship between the data elements in the structure;

4. mesh or graph structure: the data elements in the structure have many-to-many relationships;

(8) data structure storage mode: There are two different representation methods in the computer for the relationship between data elements, namely, sequential representation and non-sequential representation. The two storage methods are exported from, sequential storage structure and chain storage structure

1. sequential storage structure: the logical structure (relationship) between data elements is expressed by the relative position of data elements in the memory ).

2. chained storage structure: add a pointer to each data element to store the address of another element. this pointer is used to represent the logical structure (relationship) between data elements)
Sequential structure: the address where data elements are stored is continuous;
Chain structure: there is no requirement for the address where data elements are stored continuously.
The logical structure and physical structure of data are inseparable. the design of an algorithm depends on the selected logical structure, and the implementation of an algorithm depends on the storage structure used.

(9) data operations: Calculation of data

(10) Data Type: refers to a set of values and a group of operations defined on the value set.

(11) Algorithm (Algorithm): It is a description of the method (step) for solving a specific problem. it is a finite sequence of instructions. each instruction represents one or more operations.

(12) algorithms have the following five features:

1. poor: an algorithm must always end after a poor step is executed, and each step must be completed within a short time.

2. certainty: each instruction in an algorithm must have a definite meaning. There is no ambiguity. The algorithm has only one entry and one exit.

3. Feasibility: an algorithm can work. That is to say, the operations described by the algorithm can be achieved through the basic operations that have been implemented for a limited number of times.

4. input: an algorithm has zero or multiple inputs, which are taken from a specific object set.

5. output: an algorithm has one or more outputs. these outputs are quantities with specific relations with the input.

(13) algorithms and programs are two different concepts: a computer program is a specific implementation of an algorithm using a programming language. The algorithm must be terminable, which means that not all computer programs are algorithms.

(14) there are several criteria for evaluating a good algorithm:

1. Correctness: the algorithm must meet the requirements of specific problems.

2. Readability: the algorithm should be easy for people to read and communicate. A readable algorithm helps you understand and modify the algorithm.

3. Robustness: algorithms must be fault tolerant. When illegal or wrong data is input, the algorithm should be able to properly respond to or process the data without producing inexplicable output results.

4. Generality: the algorithm should be general, that is, the processing result of the algorithm is valid for general data sets.

5. efficiency and storage requirements: efficiency refers to the algorithm execution time; storage requirements refer to the maximum storage space required during algorithm execution. Generally, the two are related to the scale of the problem.

(15) time complexity of the algorithm: the number of repeated executions in the algorithm is a function of the problem scale n. the time measurement is recorded as T (n) = O (f (n) is called Asymptotic Time complexity.

(16) space complexity of an algorithm: a measure of the size of the storage space required to run the algorithm on a computer after it is compiled into a program. Note: S (n) = O (f (n), where n is the problem scale.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.