Discrete Math - Ch 7: Recursion & Advanced Counting

Ace your homework & exams now with Quizwiz!

Which is the correct order for the steps to find a solution of a homogeneous linear recurrence?

(1) find the characteristic equation (2) find the roots of the characteristic equation (3) compute the solution coefficients

What is the third term in this recursive function? (ch7.1) a1 = 0 an = an-1 * 2

0

Calculate the first 5 terms in this recursive function. (ch7.1) a1 = 1 an = an-1 * 2

1, 2, 4, 8, 16

Calculate the first 5 terms of this recursive function. (ch7.1) a1 = 100 an = an-1/2

100, 50, 25, 12.5, 6.25

Find the solution to the recurrence relation f(n) = 16 f(n/4) + n.

O(n2) In the given recurrence, a=16, b=4, and d=1. Comparing a and bd yields 16 > 41. So Case 3 applies and the answer is O(nlog b a) = O(nlog 4 16) = O(n2).

Find the solution to the recurrence relation f(n) = 4 f(n/8) + n2.

O(n2) In the given recurrence, a=4, b=8, and d=2. Comparing a and bd yields 4 < 82. So Case 1 applies and the answer is O(n2).

Find the solution to the recurrence relation f(n) = 8 f(n/2) + n3.

O(n3 logn) In the given recurrence, a=8, b=2, and d=3. Comparing a and bd yields 8 = 23. So Case 2 applies and the answer is O(nd logn) = O(n3 logn).

A given homogeneous linear recurrence has the following characteristic equation: s + 1 = 0. Which is the order of this homogeneous linear recurrence?

Order 1 The order of a homogeneous linear recurrence can be known according to the highest term, which in this case is s power 1. Therefore, this homogeneous linear recurrence has order 1.

Which of the following makes a recursive function? (ch7.1)

The function calls itself

What is the difference between homogeneous linear recurrences and non-homogeneous linear recurrences?

The homogeneous linear recurrences express its elements exclusively as a function of its preceding elements, while the non-homogeneous linear recurrences may also express its elements as a function of the position i of the element.

When finding the number of items in either of two sets, why does it not work to simply add the number of items in each of the two individual sets?

The items that are in common with both sets will be counted too many times.

What does the solution to a recurrence for a divide-and-conquer algorithm estimate?

The number of operations needed to solve the problem

What is the term for the collection of elements from either of two sets?

Union

The sequence <1, 3, 5, 11, 21, 43, ... > has the recursive formula and characteristic equation stated below. Mark the answer that has its solution. ai = ai-1 + 2ai-2 s^2-s-2=0

ai = (4/3)2i + (-1/3)(-1)^i Computing the roots of the characteristic equation we find s1 = 2 and s2 = -1. The initial values are, according to the question prompt a0 = 1 and a1 = 3. Computing the coefficients of the solution we find f1 = 4/3 and f2 = -1/3. Therefore, the correct solution has these coefficients 4/3 times 2 power i and -1/3 times -1 power i.

The Fibonacci sequence, < 0, 1, 1, 2, 3, 5, 8, ...> has the recursive formula and initial values as stated below. Mark the correct characteristic equation for this version of the Fibonacci sequence. a0 = 0 a1 = 1 ai = ai-1 + ai-2

s^2-s-1=0 The coefficient for the highest term (in this case s squared) has to be always equal to 1. The coefficients of the recursive formula are both 1, therefore the coefficients for the lesser terms in the characteristic equation (s and the constant) have to be -1.

Which of the following is a linear recurrence relation?

un = 3 un - 1 A linear recurrence relation has the form un = a (un - 1) + b (un - 2) + ... + c, where none of the terms are raised to a power higher than 1.

An example of a recurrence relation is _____.

un = 3 un-1 A recurrence relation shows how the present value depends on past value(s). Thus, un = 3 un-1 means the present value, un, equals 3 times the earlier value, un-1.

If a value today is 6 times the value it was yesterday, the recurrence relation is _____.

un = 6 un-1 The value today is un. The value yesterday is un-1. Thus, un = 6 un-1.

Which of the following is a first-order recurrence?

un = sin un - 1 In a first-order recurrence relation, the current value depends on a value occurring one unit of time earlier. That is, un depends on un-1, so of these answer choices the answer is un = sin un - 1

Consider an example with 100 students where 20 are taking discrete math, 30 are taking Java, 25 are taking web design, 6 are taking discrete math and Java, 8 are taking discrete math and web design, 10 are taking Java and web design and 5 are taking all three classes. How many students are taking discrete math only?

11 First take the number of students taking discrete math and subtract the number of students taking both discrete and Java. Then subtract the number of students taking both discrete and web design: 20 - 6 - 8 = 6. This will subtract the number of students taking all three classes twice, so add the number of students taking all three classes (5) to get 11.

The value at time n is the value at time (n - 1) plus 6. If the start value at time n = 0 is 4, the value at time n = 2 is _____.

16 Expressed as a recurrence relation: un = un - 1 + 6. Thus, u1 = uo + 6 = 4 + 6 = 10. And, u2 = u1 + 6 = 10 + 6 = 16.

Calculate the first 3 terms of this recursive function. (ch7.1) a1 = 2 an = an-1 + 2

2, 4, 6

Given the recurrence f(n) = 4 f(n/2) + 1, how many sub-problems will a divide-and-conquer algorithm divide the original problem into, and what will be the size of those sub-problems?

4 sub-problems, each of size n/2 For the general recurrence f(n) = a f(n/b) + g(n), a divide-and-conquer algorithm divides a problem into a sub-problems each of size n/b. In the given recurrence, a=4 and b=2, so there are 4 sub-problems, each of size n/2.

Consider an example with 100 students where 20 are taking discrete math, 30 are taking Java, 25 are taking web design, 6 are taking discrete math and Java, 8 are taking discrete math and web design, 10 are taking Java and web design and 5 are taking all three classes. How many students are not taking any of these three classes?

44 First find the number of students taking at least one of the classes (the union of the three classes) using the inclusion-exclusion principle: 20 + 30 + 25 - 6 - 8 - 10 + 5 = 56. Then subtract this number from the total number of students (100) to get 44 students taking none of the three classes.

How do we find the number of items in neither of two sets?

Find the number of items in the union of the two sets and subtract from the number of items in the universe.


Related study sets

Barron's GRE Master Words Random 2000 (1)

View Set

Big Data II Machine Learning and Deep Learning

View Set

Nurse's Touch: Professional Communication-Client Education

View Set

AC305 Chapter 4 and Chapter 5 review

View Set