How to write algorithms?

Source: Internet
Author: User

There is a more general methodology for writing algorithms, the following steps:

1. Understanding the problem

Let's figure out what the problem is.

2, analysis of the problem

What is the extent to which the problem needs to be met? Do you need an exact value or an approximate value?

3. Determine the appropriate data structure

4. Using pseudo-code to express the algorithm

This is a crucial step, basically a step in determining success or failure.

The purpose of pseudo-code is to guide the implementation of the final code, so it is clearly structured and readable.

Pseudo-code focuses on describing the execution of the algorithm, ignoring details such as variable type, partial sub-functions (such as removing the smallest element in the array, etc.) implementation.

5. Thinking about algorithm correctness and efficiency

6. Coding the final code

How to write algorithms?

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.