Classification of common algorithm problems

Source: Internet
Author: User

I. Recursive algorithm

Recursive algorithm: It is a process that calls itself directly or indirectly, but the size of each invocation of the problem is reduced, and the problem is resolved in the end.

The idea of recursive algorithm comes from the method of division and treatment.

Divide-and-conquer law: to divide a big problem which is difficult to solve is divided into several smaller problems in order to conquer, divide and conquer.

Common recursive algorithms, such as:

int fun (int n) {if (n==0| | n==1) return 1;elsereturn n*fun (n-1);}

Two. Sorting algorithms

You can refer to the previous blog:

http://blog.csdn.net/qzp1991/article/details/42002063

Three. Dynamic planning

Common problems include the sequential problem of matrix multiplication and the construction of optimal binary tree.

Four. String matching issues

Two kinds of algorithms

KMP algorithm: http://blog.csdn.net/qzp1991/article/details/42660437

BM algorithm: http://blog.csdn.net/qzp1991/article/details/42663969

Five. NP problem

It is a problem can be solved in polynomial time, such problems have not yet developed a reasonable fast algorithm.

Such as

Knapsack problem: Give n size items s1,s2 ... SN and C-capacity backpack, can find n items to fill the backpack as far as possible.

Packing problem: There are countless boxes, each box has a capacity of 1, there are n items, each item's volume is S1,S2...SN (sn<1), to accommodate the minimum number of boxes of these items (optimization problem) or given a positive integer k, can put these items into the K box (decision problem).

Hamilton Road: In an no-map, the Hamiltonian is a simple path that contains all the nodes and has only one time after each node.

Classification of common algorithm problems

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.