Solution space

table of Contents

One, solution space

Second, the relativity of the solution space

Three, solution space structure

Fourth, the relativity of the solution space structure

Five, object space

Sixth, the relationship between object space and solution space

1. Object space is equal to solution space

2. The solution space is a subspace of the object space

3. The solution space is a collection of subspaces of the object space

4. The solution space is the expansion domain of the object space (or its subspace)

5. The solution space is the space generated by the decision of the object space

Positive judgment

Reverse judgment

Seven, summary of common solution spaces of various algorithms

1. Dichotomy

Object space equals solution space

The solution space is the expansion domain of the object space (or its subspace)

The solution space is the space generated by the decision of the object space (positive decision)

2. Search

Object space equals solution space

Solution space is a subspace of object space

Solution space is a collection of subspaces of object space

The solution space is the space generated by the decision of the object space (positive decision)

The solution space is the space generated by the decision of the object space (reverse decision)

3. Dynamic programming

Object space equals solution space

Object space is not equal to solution space

4. Greed


One, solution space

The solution space of a problem is the set of all possible solutions .

In theory, any data structure imaginable may be the solution space of a certain problem.

This article is mainly aimed at searching problems, that is, finding a point that satisfies a specific condition in a space S.

For greedy problems and dynamic programming problems, it can be roughly described as taking any point A in a space S to find f(A), where f is not a function with an expression, but a complex mapping of the problem description .

 

Second, the relativity of the solution space

The concept of "possible solutions" is relativity, and correspondingly, the range of the solution space can be large or small.

For example, to find how many prime numbers are between 100 and 10,000, the solution space can be all integers between 100 and 10,000, or all odd numbers between 100 and 10,000.

 

Three, solution space structure

The spatial structure of the solution space is called the solution space structure, such as arrays, linked lists, trees, and so on.

 

Fourth, the relativity of the solution space structure

For a problem, different algorithms may have different solution space structures, even if the set of solutions used by the two algorithms is the same.

For example, find out how many digits from 1 to 9999 add up to 9.

If you use sequential search, the solution space structure is an array from 1 to 9999. If you use a tree search, then the solution space structure is a 5-layer dictionary tree.

 

Five, object space

The space in which the research object of the problem is located is called the object space .

Generally speaking, the object space is the most intuitive concept and the intrinsic property of the problem. It has nothing to do with the algorithm, and the solution space is dependent on the algorithm.

 

Sixth, the relationship between object space and solution space

There are many kinds of relationships between object space and solution space. Based on years of ACM experience, I think there are several common relationships as follows:

1. Object space is equal to solution space

For example, enter an array and find the largest number in it.

The object space is the array itself, and the solution space is also the array itself.

2. The solution space is a subspace of the object space

For example, enter n numbers and find all prime numbers among them.

The object space is n numbers, and the solution space is all prime numbers in it.

3. The solution space is a collection of subspaces of the object space

For example, in the maze problem, the object space is a matrix, and the solution space is a collection of all possible paths.

Another example is the N queen problem. The object space is a matrix, and the solution space is all N for choosing a queen in each row and column! A collection of selection methods.

PS: The difference between the above two types is that one is an individual's independent judgment and the other is a collective comprehensive judgment.

4. The solution space is the expansion domain of the object space (or its subspace)

For example, input n real numbers and find their average.

The object space is n real numbers, and the solution space is all real numbers.

5. The solution space is the space generated by the decision of the object space

Positive judgment

For example, input n positive integers, choose k numbers from them, and find the mean value x of the prime numbers

Reverse judgment

For example, input n integers and find the smallest positive integer k so that you can choose k numbers from them, and the mean of the prime numbers is at least x

PS: Maybe the bigger the k is, the bigger the x is, but there is no problem with the expression of the title. As long as a number is satisfied, there must be such a minimum k.

 

Seven, summary of common solution spaces of various algorithms

1. Dichotomy

 Typical questions in https://blog.csdn.net/nameofcsdn/article/details/111825915 :

Object space equals solution space

HDU 2141 Can you find it? (Find the sum of three numbers, two points)

The solution space is the expansion domain of the object space (or its subspace)

HDU 1969 PIE (Solving equations)

The solution space is the space generated by the decision of the object space (positive decision)

CSU 1984: LXX ability value

PS: The dichotomy of forward judgment is a popular understanding that directly dicates the answer, but it is not as intuitive as the dichotomy of finding the solution of an equation.

2. Search

 Typical questions in https://blog.csdn.net/nameofcsdn/article/details/111918584 :

Object space equals solution space

Likou OJ 111. The minimum depth of a binary tree

Solution space is a subspace of object space

CSU 1660 K-Cycle

Solution space is a collection of subspaces of object space

HDU 1016 Prime Ring Problem (full permutation problem), the object space is the entire permutation, and the solution space is the permutation that satisfies the conditions.

HDU 1455 Sticks (combination)

HDU 2102 Plan A (Maze)

HDU 2553 N Queen Question

SGU454 Kakuro

POJ 3126 Prime Path (prime number conversion path)

The solution space is the space generated by the decision of the object space (positive decision)

HDU 1241 Oil Deposits (number of connected blocks)

The solution space is the space generated by the decision of the object space (reverse decision)

CSU 1224: Weird chess of the ACM team

3. Dynamic programming

For search problems, the object space is very clear, the solution space is not so clear, the object space and the solution space are better to distinguish.

But for dynamic programming, there is basically no distinction between object space and solution space, so the solution space of dynamic programming that I mentioned on other occasions (including blogs) may be directly object space.

And on some occasions, I use the good base set of dynamic programming to describe it, reference: interval DP  https://blog.csdn.net/nameofcsdn/article/details/112981922

Dynamic programming can be simply divided into two categories according to whether the object space is equal to the solution space:

Object space equals solution space

Sequence DP  https://blog.csdn.net/nameofcsdn/article/details/112771904

Interval DP  https://blog.csdn.net/nameofcsdn/article/details/112981922

Tree DP  https://blog.csdn.net/nameofcsdn/article/details/113070354

Object space is not equal to solution space

Asymmetric DP  https://blog.csdn.net/nameofcsdn/article/details/113064148

Digital DP  https://blog.csdn.net/nameofcsdn/article/details/113071516

4. Greed

As above, greedy, like dynamic programming, both depends on the properties of optimal substructures, so they are all based on well-founded sets.

Guess you like

Origin blog.csdn.net/nameofcsdn/article/details/111885131