A progressive Method for Solving recursive equations -- Iterative Method

Source: Internet
Author: User
Tags floor function
ArticleDirectory
    • A progressive Method for Solving recursive equations -- Iterative Method
A progressive Method for Solving recursive equations -- Iterative Method

This method is used to estimate the approximate order of the Solution of recursive equations. It does not require the approximate expression of the speculative solution, but requires many algebra operations. The idea of the method is to iteratively expand the right end of the recursive equation to make it a non-recursive sum, and then estimate the left end of the equation, that is, the solution of the equation, through the estimation of the sum.

As an example, consider recursive equations:

You can expand the right side of the secondary iteration as follows:

The floor function has an equality:

The formula (6.10) can be simplified:

This is still a recursive equation, and the right side should be expanded. It is easy to see that IterationIAfter

(6.11)

And when

(6.11) is no longer a recursive equation. At this time:

(6.13)

Because [A] ≤A, From (6.13:

And by (6.12), ZhiI≤ Log4NTo

,

Generation (6.14:

That is, the solution of the equation (6.9 ).T(N) =O(N).

From this example, we can see that iterative methods lead to complicated algebra operations. However, the main point is to determine the number of iterations that meet the initial conditions and grasp the "free term" produced by each iteration (TItems) follow the rules. By the way, it is pointed out that the results of the first iteration of the iteration method often inspire us to give a correct estimation of the gradual order of the solution of the recursive equation. In this case, if you use the substitution method, the preceding complex algebra operations can be avoided.

Figure 6-1 recursive tree corresponding to equation (6.15)

We introduceRecursive tree. By using the recursive tree, people can quickly obtain the approximate order of the solution of the recursive equation. It classifies descriptionsAlgorithmThe recursive equation is particularly effective. We use recursive Equations

T(N) = 2T(N/2) +N2 (6.15)

As an example. Figure 6-1 shows (6.15) the evolution of the recursive tree during iteration. For convenience, we assume thatNIt is the power of 2. Here, the recursive tree is a binary tree, because (6.15) recursive item 2 on the right sideT(N/2) can be viewedT(N/2) +T(N/2 ). Figure 6-1 ()T(N) Is concentrated at the root of the recursive tree. (B) indicatesT(N) Is expanded by (6.15. That is, it will constitute its free term.N2 stay in the original place, and 2 recursive itemsT(N/2) spread it to the two son nodes. (C) indicates that the iteration is executed once. Figure 6-1 (d) shows the final result of the iteration.

Figure 6-1 shows that the sum of values of all nodes in each recursive tree is equalT(N). In particular, the sum of values of all nodes in the recursive tree (d) that does not contain recursive items is also true. Our goal is to estimate the sumT(N). We can see a tabular approach: first, calculate the sum of the values of each layer node horizontally, and record it at the top right side of each corresponding layer, then, from the root to the leaves, adding the result of the top lattice is the result we requested. According to this, we obtain the approximate order of the (6.15) solution.θ(N2 ).

Here is another example. Recursive equation:

T(N) =T(N/3) +T(2N/3) +N(6.16)

The corresponding recursive tree of the iteration process is shown in 6-2. For simplicity, the floor function and ceiling function are skipped again.

Figure 6-2 recursive tree for iterative solution (6.16)

When we accumulate values of each layer of the recursive tree, the sum of each layer is equalNThe longest path from root to leaf is

Set the maximum path lengthK, You should have

,

Get

,

Therefore

That isT(N) =O(NLogN).

The above two examples show that the iterative method is very easy to use with the help of recursive tree.


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.