Data structure and algorithm 2016-06-01

Source: Internet
Author: User

1. The data structure consists of the logical and physical structure. The logical structure of data is a mathematical model abstracted from specific problems, it is to discuss the convenience of the problem, and the data is not related to the specific storage in the computer. The purpose of the discussion data structure is to implement it in the computer, so we also need to study how to represent and store the data structure in the computer, that is the physical structure. The physical structure of the data, also known as the storage structure, is the representation and storage of the data in the computer (aka imagery) and storage, including the representation and Sonjuku of the data elements and the relationships between the data elements.

2. The data storage structure consists of sequential storage structure and chain storage structure. Sequential storage structure is the logical relation of data element by the relative position of data element in computer memory, and the logically adjacent data element is stored in the adjacent storage unit of the physical location. The sequential storage structure is implemented in the C # language using arrays. Since the storage space allocated by the array is contiguous, the array is inherently capable of implementing the data order storage structure. A chained storage structure that is logically adjacent to an element does not require its storage location to be contiguous. The data element in a chained storage structure is called a node, and an address field is attached to it to store the address of the node adjacent to it to achieve the logical relationship between nodes. This address is called a reference and this address field becomes the reference domain.

3. The algorithm is a description of the solution steps for a particular type of problem, which is a finite sequence of instructions. Each of these instructions represents one or more operations. An algorithm should have the following 5 features:

Poor: An algorithm always ends after performing a poor step, that is, the execution time of the algorithm is limited.

Determinism: Every step of the algorithm must have a definite meaning, i.e. no ambiguity, and only the same output for the same input.

Input: An algorithm has 0 or more inputs. It is the amount of data that is given before the start of the algorithm, and these inputs are the objects of the object in some structure.

Output: An algorithm has one or more outputs, and there is a specific relationship between these outputs and the input.

Performance: Each step in the algorithm can be implemented with a finite number of runs of the basic operations already implemented.

4. Evaluation criteria for algorithms

Correctness: The execution result of the algorithm should meet the requirements of pre-defined function and performance, which is the most important and basic criterion to evaluate an algorithm. The correctness of the algorithm also includes a clear and unambiguous description of the input and output processing.

Readability: The algorithm is mainly for people to read and communicate, followed by the implementation of the robot. So an algorithm should be clear-minded, hierarchical, simple and clear, easy to read and understand. The timely algorithm has turned into a machine executable program, also need to consider people can better read comprehension, at the same time, a readable algorithm can also help to the algorithm of the exclusion of hidden errors and the migration of algorithms.

Robustness: An algorithm should have a strong fault tolerance, when the input of illegal data, the algorithm should be able to do the appropriate processing, so as not to cause serious consequences, robustness requires the surface algorithm to carefully and comprehensively consider all possible boundary conditions and anomalies, and to these boundary conditions and abnormal conditions to properly handle, Make the algorithm as far as possible without unexpected occurrences.

Run time: Run time is the amount of time the algorithm takes to run on a computer, which equals the sum of the execution time of each statement in the algorithm. For the same problem, if you have more than one algorithm to choose from, you should choose an algorithm with a short execution time whenever possible. In general, the shorter the execution time, the better the performance.

Occupy Space: Space is the amount of storage space used by the algorithm to store on the computer, including the storage space occupied by the storage algorithm itself, the input of the algorithm and the storage space occupied by the output data, and the storage space occupied by the algorithm during the running process. The storage space used by the algorithm is the maximum amount of storage space required during the execution of the algorithm, and the algorithm with low storage demand is chosen as much as possible. The size of the storage space that the algorithm occupies temporarily during running is called the space complexity of the algorithm.

Data structure and algorithm 2016-06-01

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.