Algorithm review-Research on

Source: Internet
Author: User

Algorithm review

Topics included: Greedy algorithms, divide-and-conquer methods, dynamic programming, backtracking, branch-bound, linear programming

Key words: Optimal sub-structure

Q: Greed and dynamic planning in the middle of the relationship and difference p93 back (back problem, 0-1 knapsack problem)

recursive divide and conquer algorithm

Basic idea: Divide a big problem into several small sub-problems, divide and conquer

General steps: 1. Decomposition of the original problem into a number of small, mutual independence and the original problem form the same problem 2. Solve, solve each sub-problem, when the problem is divided into small enough, it can be easily solved 3. Merging, merging sub-problems by layer, and getting the final Solution

Classic Questions

Two-point search:

Merge sort (divides the sequence that you want to sort into two subsets of the same size, and then sorts, then merges O (NLOGN)): The partitioning strategy is similar to a binary search, by recursively returning layers of layers until only one, and then a layer of merging

Quick sort: (the sequence is divided into two subsets according to A[i], the first subset is smaller than A[i], the second subset is larger than A[i):

Large integer multiplication (to accurately find the value of all the digits of a large integer in a multiplication operation, it is necessary to use the method of software):

There are repeated and non-repeating permutation problems

Greedy Algorithm

Basic idea: The greedy algorithm always makes the best choice, and he expects to get the global optimal solution by local optimal solution.

There are two characteristics that can be solved by greedy algorithm: the Greedy choice property (the whole optimal solution of the original problem can be obtained by a series of local optimal selection), the optimal sub-structure (the optimal solution of a problem, including the optimal solution of its sub-problem) (because of its optimal substructure, can be solved by dynamic programming, But greed will be simpler)

The problem of classic greedy selection

Select sort each time the largest one is selected from the remaining sequence, forming the final optimal solution

Bubble sort

Optimal loading (how to load the most cargo) with the lightest weight preferred greedy strategy

Event scheduling (with limited time for meetings with no conflict of meeting times) 1. The choice of greedy strategy, a. The earliest start-to-time conflict policy, B. Minimum duration vs. conflict-less policy c. The earliest end time and conflict policy we choose c greedy strategy,

Huffman Coding: (prefix code, any one character code can not be the prefix of other characters to obtain the best coding scheme) greedy strategy: Select two nodes with the smallest weights in all nodes as the left and right nodes of the new tree, forming a new node, and the weights are the sum of the two

Single Source Shortest path (Dijkstra algorithm, the shortest path (interpolation method)): Greedy strategy, starting from the initial state, one by adding the value of the connection, and then find the shortest path of all the current nodes, when all the points are joined, is the final result

Minimum spanning tree:

Prim algorithm (plus edge): Greedy strategy: In the current subtree, select the minimum weight associated with it and do not form the edge of the ring

Kruskal algorithm (Edge selection): Greedy strategy: In all edges, select the smallest and non-formed edge

Multi-Machine scheduling problem:

Exercises

Algorithm review-Research on

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.