Principles of designing algorithms, what are the principles of algorithm design

Updated on technology 2024-07-22
9 answers
  1. Anonymous users2024-02-13

    1. Correctness: The correctness of the algorithm means that the algorithm should at least have no ambiguity in input, output and processing, be able to correctly reflect the needs of the problem, and be able to get the correct answer to the problem.

    2. Readability: The purpose of designing the algorithm is, on the one hand, to allow the computer to execute, but also to facilitate the reading of others, so that people can understand and communicate, and they can read it in the future. If the readability is not good, you don't know what you wrote for a long time, and readability is a very important indicator of the quality of the algorithm (including the program that implements it**).

    3. Robustness: When the input data is illegal, the algorithm should react appropriately or deal with it accordingly, rather than inexplicably outputting results. And the way to handle the error should not be to interrupt the execution of the program, but to return a value that represents the error or the nature of the error, so that it can be handled at a higher level of abstraction.

    4. High efficiency and low storage: Generally, the efficiency of the algorithm refers to the execution time of the algorithm; The amount of storage required for an algorithm is the maximum storage space required during the execution of the algorithm, and the complexity of both is related to the size of the problem. The task of algorithm analysis is to use mathematical tools to discuss the complexity of each specific algorithm designed, and the adaptability of the specific algorithm to the problem.

  2. Anonymous users2024-02-12

    The principle of designing the algorithm: avoid the subtraction of two similar numbers, avoid being eaten by decimals when two orders of magnitude are very different from each other, minimize the number of operations in the algorithm, avoid using the number with an absolute value too small as a divisor, and prevent the accumulation of errors from increasing in recursive operations.

  3. Anonymous users2024-02-11

    Principle: First of all, the algorithm of the design must be"Right", and secondly there should be good"Readability", which must also have"Robustness"Finally, the designed algorithm should be considered to have"High efficiency and low storage capacity"。

    The so-called algorithm is correct, except that it should meet the requirements of the algorithm description"features"In addition, correct results should be obtained for each set of typical input data with harsh conditions.

    On the premise that the algorithm is correct, the readability of the algorithm is the first priority, which is especially important in today's environment where large software requires multiple people to work together, on the other hand, obscure programs are easy to hide errors and difficult to debug. The efficiency of the algorithm refers to the execution time of the algorithm, and the storage amount of the algorithm refers to the maximum storage space required during the execution of the algorithm.

    Algorithms are another indispensable element of programming, so it is inevitable to discuss the corresponding algorithms along with the discussion of data structures. There are two meanings here, that is, there are a finite number of operation steps in the algorithm, and each step can be completed in a finite time.

    Determinism is manifested in the fact that there is no ambiguity in the description of each step in the algorithm, as long as the input is the same and the initial state is the same, the result should be the same no matter how many times it is executed.

    Feasibility means that each operation in the sequence can be done simply without algorithmic problems, e.g.,"Find the common factors of x and y"It's not basic enough.

    The input value is the operation object of the algorithm, but the operation object can also be generated by the algorithm itself, such as"Find prime numbers within 100", the operands are natural sequences that can be generated by incrementing 1 by variables one by one.

    The robustness of an algorithm means that the algorithm should properly reflect or process the data entered illegally, and in general, it should return a value that represents the error or the nature of the error to the function that called it.

  4. Anonymous users2024-02-10

    Wrote a paragraph of fortran**, the algorithm is detailed in the comment (green text).

    Attached: Results of the simulation run and **.

  5. Anonymous users2024-02-09

    The algorithm design strategy is as follows:

    1. Divide and conquer HTML

    The design idea of the divide and conquer method is to divide a large problem that is difficult to solve directly into k smaller sub-problems, which are independent of each other and the same as the original problem, and then each of them is broken down and divide and conquer. Algorithm.

    2. Dynamic planning of SPA

    Similar to the partition method, the basic idea of dynamic programming is to decompose the original problem into several sub-problems. In this case, it is obviously not necessary to use the divide and conquer method to solve some sub-problems repeatedly. In the process of solving, the dynamic programming method saves the answers to all the solved sub-problems, so as to avoid repeated solutions to the sub-problems.

    3. Greed. When a problem has the optimal substructure properties, it can be solved by dynamic programming. But sometimes there is a simpler, more direct, and more efficient algorithm than dynamic programming – the greedy method.

    The greedy pharaoh makes the best choice at the moment, that is to say, the greedy pharaoh does not consider the overall optimality, but only the local optimal choice in a sense.

    4. Backtracking. The backtracking method is to perform a deep-first search on the solution space tree of the problem, but before DFS each node, it is necessary to determine whether the node may contain the solution of the problem. If it is determined that it does not contain it, the search for the subtree rooted by the node is skipped, and the search is layered back to its ancestor node.

    If it is possible, enter the subtree and perform DFS.

    5. Branch limits.

    The backtracking method is a depth-first search of the solution space, and in fact any algorithm that searches the entire solution space can solve the problem. Therefore, any implementation of generic graph search as a search strategy can solve the problem, as long as it is exhaustive. In addition to depth-first search, we can also use breadth-first search, and the branch limit rule is to perform a priority-first search of the solution space.

  6. Anonymous users2024-02-08

    To evaluate a good algorithm in the data structure, it should be considered from four aspects, namely:

    First, the correctness of the algorithm.

    Second, the legibility of the algorithm.

    Third, it is the robustness of the algorithm.

    Fourth, it is the spatiotemporal efficiency (operation) of the algorithm.

    The design of the algorithm depends on the data (logical) structure, and the implementation of the algorithm depends on the storage structure employed. The storage structure of data is essentially the implementation of its logical structure in computer memory. In order to fully reflect the logical structure of a piece of data, its image in memory consists of two aspects, namely information between data elements and relationships between data elements.

    Different data structures have corresponding operations. Manipulation of data is an algorithm of operations defined on the logical structure of data, such as retrieval, insertion, deletion, update, and sorting.

  7. Anonymous users2024-02-07

    Time complexity, spatial complexity, requirements.

  8. Anonymous users2024-02-06

    It's easy to implement, and the processing speed of the computer is fast! I used to see a sentence that said: don't leave the problem that you can solve by yourself to the computer, the computer is to help the user solve the problem. That should be all there is to it!

  9. Anonymous users2024-02-05

    Algorithms are the core of computer science, and they solve the methods and rules of various practical problems. In computer programming, it is crucial to write a good aristry algorithm. The guidelines for algorithm design are a set of deterministic rules that ensure the correctness, efficiency, and maintainability of the algorithm in solving real-world problems.

    This article will summarize the most important aspects of the algorithm design guidelines.

    Correctness The correctness of an algorithm refers to the ability of the algorithm to produce the correct results as expected. Correctness is the most basic requirement and criterion in algorithm design. When designing an algorithm, it is important to consider a variety of situations to ensure that the algorithm can handle different inputs and boundary conditions.

    In addition, the algorithm needs to be formally validated and tested to identify and fix potential errors.

    Efficiency The efficiency of an algorithm refers to the speed and space utilization of the algorithm when it is able to handle large amounts of data. In actual programming, time complexity and spatial complexity are two important indicators that are used to evaluate the efficiency of algorithms. When designing an algorithm, you should consider how to reduce the computational time and footprint of the algorithm.

    Techniques such as optimizing with data structures, using dichotomies, preprocessing, etc., can greatly improve the efficiency of the algorithm.

    Maintainability The maintainability of an algorithm refers to the ability of an algorithm to remain clear, extensible, and reusable in future modifications and maintenance. When designing algorithms, you should follow good programming habits, write clear, easy-to-understand, annotated **, and follow a number of such as:"Single duty principle"、"Open-closed principle"and other design guidelines to ensure that the program is maintainable.

    Conclusion This article introduces the most important aspects of algorithm design guidelines: correctness, efficiency, and maintainability. The correctness of the algorithm is the basic requirement of algorithm design, which can be verified by early and clever verification and testing.

    The efficiency of an algorithm refers to the speed and space utilization of the algorithm when it is able to handle large amounts of data. When designing an algorithm, you should consider how to reduce the computational time and footprint of the algorithm. Maintainability of an algorithm refers to the ability of an algorithm to remain clear, scalable, and reusable in future modifications and maintenance.

    When designing algorithms, good programming habits and design guidelines should be followed to ensure that the program is maintainable.

Related questions
10 answers2024-07-22

After understanding the basic working principle and instruction system of PLC, you can combine the design of PLC with the actual situation, the design of PLC includes two parts: hardware design and software design, and the basic principles of PLC design are: 1Give full play to the control function of PLC to meet the control requirements of the controlled production machinery or production process to the greatest extent. >>>More

6 answers2024-07-22

8 guiding principles: the principle of objectives, the principle of conformity, the principle of responsibility, the principle of organizational hierarchy, the principle of management range, the principle of specialization, the principle of coordination and the principle of clarity.

7 answers2024-07-22

Color matching: First, the color matching should follow the principle of contrast. Generally speaking, colors are contrasted in terms of purity, brightness, hue, chiaroscuro, shade, cold and warm contrast, etc. >>>More

11 answers2024-07-22

1. Cultural themes. The cultural theme exhibition hall is faced with the audience who is interested in culture, and the designer can highlight the cultural atmosphere of the exhibition hall through things such as lighting, multi-** and exhibits, highlighting the focus and central exhibits in the design process. So as to attract the attention and interest of the audience, so that the experience of visitors is more profound. >>>More

8 answers2024-07-22

The design principles of the compensation system design include the following aspects: >>>More