

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


(40 respondents)
โ 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.
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.
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.
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
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.
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.
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
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.
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