Docsity

Recurrence Equations-Aeronautical Engineering And Computer Programming-Lecture Slides, Slides of Aeronautical Engineering

Toggle sidebar
bg1
Lecture C13: Recurrence equations
Response to 'Muddiest Part of the Lecture Cards'
(40 respondents)
1) What does Recurrnece Equations got to do with programming? and similar questions (6 students)
Recurrence equations provide a means of expressing the cost of an algorithm as a function of the size of
the input. For example, with the Towers of Hanoi problem, moving 4 disks from tower 1 to tower 3 can
be broken down into:
โ— Moving 3 disks from tower 1 to tower 2
โ— Moving 1 disk from tower 1 to tower 3
โ— Moving 3 disks from tower 2 to tower 3.
If the cost of solving n disks is T(n), from the above breakdown, we can express T(n) as:
C when n = 1
T(n)
=
2T(n-1) + c when n >
1
This above representation is called a recurrence equation with T(n = 1) being the base case.
2) What exactly does the cost of a procedure entail? What is the benefit of calculating the efficiency/
cost of a function? and similar questions (5 students)
The cost of an algorithm can be measured in terms of memory usage, processor usage or a combination
of the two. When you are trying to compare the efficiency of two or more algorithms, you want to be
able to compute the cost of the problem as a function of the size of the problem. The two functions can
then be compared to determine the conditions under which one algorithm is better than the other. We
will see more of this next semester when we talk about algorithm complexity.
3) What is the purpose of Extended Euclid's algorithm, what is it used for? and similar questions (4
students)
The extended Euclids algorithm allows the user to solve the Diophantine equations i.e. it provides the
user with a method for expressing an integer as a sum of products. When we are doing long division, we
need to express a large number as a sum of products of two smaller numbers. We use the extended
docsity.com
pf3

Partial preview of the text

Download Recurrence Equations-Aeronautical Engineering And Computer Programming-Lecture Slides and more Slides Aeronautical Engineering in PDF only on Docsity!

Lecture C13: Recurrence equations

Response to 'Muddiest Part of the Lecture Cards'

(40 respondents)

  1. What does Recurrnece Equations got to do with programming? and similar questions (6 students) Recurrence equations provide a means of expressing the cost of an algorithm as a function of the size of the input. For example, with the Towers of Hanoi problem, moving 4 disks from tower 1 to tower 3 can be broken down into:

โ— Moving 3 disks from tower 1 to tower 2 โ— Moving 1 disk from tower 1 to tower 3 โ— Moving 3 disks from tower 2 to tower 3.

If the cost of solving n disks is T(n), from the above breakdown, we can express T(n) as:

C when n = 1 T(n) = 2T(n-1) + c when n > 1

This above representation is called a recurrence equation with T(n = 1) being the base case.

  1. What exactly does the cost of a procedure entail? What is the benefit of calculating the efficiency/ cost of a function? and similar questions (5 students) The cost of an algorithm can be measured in terms of memory usage, processor usage or a combination of the two. When you are trying to compare the efficiency of two or more algorithms, you want to be able to compute the cost of the problem as a function of the size of the problem. The two functions can then be compared to determine the conditions under which one algorithm is better than the other. We will see more of this next semester when we talk about algorithm complexity.

  2. What is the purpose of Extended Euclid's algorithm, what is it used for? and similar questions ( students) The extended Euclids algorithm allows the user to solve the Diophantine equations i.e. it provides the user with a method for expressing an integer as a sum of products. When we are doing long division, we need to express a large number as a sum of products of two smaller numbers. We use the extended

Euclid to generate the products.

  1. Don't understand how GCD(a, b) = ap + bq and how that translates t osomething mod something else? and similar question (2 students) Lets take an example and work through it:

Assume that I want to find the GCD of 38 and 10.

Step 1. Divide 38 by 10 and find the remainder. In this case, it is 8. I can now express 8 as a function of 38 and 10 (multiply the quotient by the divisor, add the remainder to get the dividend). 38 mod 10 = 8 = 38 โ€“ 3 * 10

Step 2. The new numbers are 10, 8. Repeat step 1 on the numbers. 10 mod 8 = 2 = 10 โ€“ 1 * 8

Step 3. 8 however can be replaced with the sum of products computed in step 1. Hence 2 = 10 โ€“ 1(38 โ€“ 3 * 10) = 410 โ€“ 1 *

2 is the GCD(38,10), hence the GCD can be written as a linear combination of the numbers

  1. What about the last slide the equation and recurrence tree? (2 students) The recurrence tree provides another means of solving the recurrence function and will be covered in detail next semester.

  2. What is the reading assignment for this lecture? (1 student) Go over the lecture slides and the recursion handout. Those two should be sufficient as reading.

  3. Can MOD and REM work with types other than Integer? (2 students) Mod and Rem are defined for modular types. They work on integers, user defined mod types and subtypes of integers

  4. Will we need to be able to break an equation into a requrrence equation or vice versa? (2 students) You should be able to visualize the breakdown of the problem into simpler parts. For this semester, you will not be expected to generate the recurrence equation. You will be expected to be able to solve a given recurrence equation using the iteration method.

  5. I do not understand "T(n) < 3T(n/2) + cn"? (2 students) Consider two really large integers each with six digits. For the sake of simplicity, let us consider decimal arithmetic.

The number x can be expressed as a linear combination of two integers. For example 123456, can be