Using Induction to design use inductive design algorithm [2/14]

Source: Internet
Author: User

Link: http://blog.csdn.net/jj12345jj198999/article/details/6600734

 

This is a very powerful and flexible method. We will prove that it will surprise you to have many very simple questions when using this idea. We will use several of these methods and show their strength in designing algorithms. In the various deformation methods of induction we discuss, we mainly discuss four methods: Clever selection of induction sequence, enhanced induction hypothesis, stronger induction and the largest inverse example.

Our processing methods have two novelty. First, we classify seemingly different algorithm design technologies into the same category, which makes searching for a new algorithm more rational. Secondly, we use known mathematical proof techniques to design algorithms. This is very important, this is because it has started the era of algorithm design by leveraging powerful technologies that have been formed during years of development in other disciplines.

Generally, it is not the first time to use induction and mathematical proof techniques in the field of algorithms. Induction has been used for a long time to prove the correctness of the algorithm. People have proved by the assertions of the algorithm's execution steps that they are initially established and they remain unchanged under the specific operation steps, to verify the correctness of the algorithm. This method was initially proposed by cotus and von noriman, and was further developed by freusi and others. Dijkstra and geris proposed a method similar to our program development, and they also provided proof of its correctness. Although we have used some of their technologies here, our focus is different: we focus on high-level algorithm concepts without having to go down to the actual program layer. The basic components of a program development system are the use of mathematical proofs. Of course, recursion is also widely used in algorithm design (for details about recursion, see ...)

Our goal is mainly for teaching. We assume that readers are familiar with mathematical induction and basic data structures. For any proof technique, we will give a brief explanation of its analogy and give one or more examples of algorithms. For the given algorithm example, we focus on how to use this method. Our goal is not to explain an algorithm so that a programmer can easily convert it into a program, but to explain it in a more understandable way. These algorithms are interpreted through a creative process rather than in a finished form. The goal of teaching algorithms is not only to show students how to solve specific current problems, but also to help them solve new problems in the future. It is equally important to teach students how to integrate ideas into algorithm design and to teach them how to implement solutions. But the former is usually more difficult. We believe that our approach can enhance our understanding of this process of thinking.

Although the induction method is recommended to be implemented through recursion, this is not necessarily the case. (In fact, we call this method induction rather than recursion to dilute the concept of Recursive Implementation.) In many cases, iteration is also easy, even though we want to use induction (recursion) in algorithm design, iteration is more efficient.

The algorithms mentioned in this article are filtered to better demonstrate the charm of this method. We chose some simple problems and selected some more complex examples in the subsequent sections. We found that many fixed algorithms can be used for the first time in algorithm design classes. (The Introduction to algorithms using this method is coming soon.) Let's start with three simple examples (at least use induction to make them look simple) then we show some mathematical proof techniques and similar techniques in algorithm design. In each case, this analogy is illustrated in one or more examples.

 

 

 

Three examples

 

Calculate the polynomial value [Q1]
Problem: given a real number sequence an, An-1,... A1, A0 and a real number X, calculate the value of the polynomial below
Pn (x) = An * x ^ N + an-1 * x ^ (n-1) +... A1 * x + a0
This problem does not seem like an intuitive example of using induction to solve the problem. However, we will prove that using induction can directly bring about a good solution. We first use the simplest and almost insignificant method to solve the problem, and then find a better solution by discovering the changes.

This problem involves N + two numbers. The induction method is used to solve a smaller problem. In other words, we try to reduce the problem scale and then use recursive solutions. (Or we call it induction) The first step is to remove an, which will cause the expression calculated in the problem to become:
Pn-1 (x) = An-1 * x ^ (n-1) + an-2 * x ^ (n-2) +... + A1 * x + a0
In addition to the scale, this is the same problem. Therefore, we can use the following assumptions to solve them by induction:
Inductive hypothesis: we already know how to calculate a polynomial. The input items of this polynomial at x include an-1 ,... a1, a0 (that is, we know how to calculate Pn-1 (x ))

Now we can use this assumption to solve this problem using induction. First, we need to solve the most basic situation, that is, calculate A0; this is very simple. Then we must demonstrate how to solve the original problem (that is, calculate Pn (x) by using a solution to a smaller problem (here the value of Pn-1 (x )). This is intuitive in this example. We only need to calculate x ^ N, multiply by an and then add Pn-1 (X.

At this point, it seems boring to use induction because it is just a complicated and simple solution. The algorithm mentioned above is just to calculate the polynomial from right to left by the polynomial mathematical method. However, we will soon see the power of this method.

Although this algorithm is correct, it is not efficient. It requires n + n-1 + N-2 +... + 1 = n (n + 1)/2 multiplication and N addition calculation. Now we can slightly change the method of induction to get a better solution.

 

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.