1/47
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Pre-Assessment: Algorithms - Algorithm Structures:
Question 1:
Consider the following pseudocode that merges two lists of numbers into one:
Merge0(List1, List2)
Set OUTlist to empty
While List1 is not empty OR List2 is not empty
If one list is empty and the other is not,
Remove the first number from the non-empty list and add it to OUTlist
If both lists are non-empty,
Remove the first number from List1 and add it to OUTlist
Remove the first number from List2 and add it to OUTlist
Return OUTlist
If ListA is [1, 3, 5] and ListB is [2, 4, 6] then what is the result of Merge0 (ListA, Merge0 (ListB, ListA))?
[ 1, 2, 3, 1, 5, 4, 3, 6, 5 ]
Step 1:
To solve this, we need to understand how the Merge0 function works. It merges two lists by taking the first element of each list and adding it to the output list in ascending order. If one list is empty and the other is not, it removes the first element from the non-empty list and adds it to the output list.
Using the given example, we have:
ListA = [1, 3, 5]
ListB = [2, 4, 6]
Now, let's analyze the innermost function Merge0(ListB, ListA):
1. OUTlist = empty
2. OUTlist = [2]
3. OUTlist = [2, 1]
4. OUTlist = [2, 1, 4]
5. OUTlist = [2, 1, 4, 3]
6. OUTlist = [2, 1, 4, 3, 6]
7. OUTlist = [2, 1, 4, 3, 6, 5]
8. ListA is now empty, so we return OUTlist = [2, 1, 4, 3, 6, 5]
Step 2:
Now, let's use the result of Merge0(ListB, ListA) as the second argument for the outer Merge0 function. So we have:
List1 = ListA = [1, 3, 5]
List2 = Merge0(ListB, ListA) = [2, 1, 4, 3, 6, 5]
Using the Merge0 function with these lists, we have:
1. OUTlist = empty
2. OUTlist = [1]
3. OUTlist = [1, 2]
4. OUTlist = [1, 2, 3]
5. OUTlist = [1, 2, 3, 1]
6. OUTlist = [1, 2, 3, 1, 5]
7. OUTlist = [1, 2, 3, 1, 5, 4]
8. OUTlist = [1, 2, 3, 1, 5, 4, 3]
9. OUTlist = [1, 2, 3, 1, 5, 4, 3, 6]
10. OUTlist = [1, 2, 3, 1, 5, 4, 3, 6, 5]
11. return OUTlist = [1, 2, 3, 1, 5, 4, 3, 6, 5]
Therefore, the result of Merge0(ListA, Merge0(ListB, ListA)) is [1, 2, 3, 1, 5, 4, 3, 6, 5].
Pre-Assessment: Algorithms - Algorithm Structures:
Question 2:
Given this pseudocode:
S = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
x = 2
While(x<11):
For i in S:
If 0 ≡ i mod x and i ≠ x:
delete i from S
end-If
end-For
x = x + 1
end-While
What is S at the end of this code?
{2, 3, 5, 7, 11, 13, 17, 19}
This code is nothing but finding the prime numbers from the given set.
Start from x = 2
1) When x = 2, we have to delete that elements from S which satisfy 0 == i mod 2 and i ≠ 2 i.e multiples of 2 except 2. So we remove {4, 6, 8, 10, 12, 14, 16, 18, 20}
x = x+1
2) When x = 3, we have to delete that elements from S which satisfy 0 == i mod 3 and i ≠ 3 i.e multiples of 3 except 3. So we remove {6, 9, 12, 15, 18}
x = x+1
3) When x = 4, we have to delete that elements from S which satisfy 0 == i mod 4 and i ≠ 4 i.e multiples of 4 except 4. So we remove {8, 12, 16, 20}
x = x+1
4) When x = 5, we have to delete that elements from S which satisfy 0 == i mod 5 and i ≠ 5 i.e multiples of 5 except 5. So we remove {10, 15, 20}
x = x+1
5) When x = 6, we have to delete that elements from S which satisfy 0 == i mod 6 and i ≠ 6 i.e multiples of 6 except 6. So we remove {12, 18}
x = x+1
6) When x = 7, we have to delete that elements from S which satisfy 0 == i mod 7 and i ≠ 7 i.e multiples of 7 except 7. So we remove {14}
x = x+1
7) When x = 8, we have to delete that elements from S which satisfy 0 == i mod 8 and i ≠ 8 i.e multiples of 8 except 8. So we remove {16}
x = x+1
8) When x = 9, we have to delete that elements from S which satisfy 0 == i mod 9 and i ≠ 9 i.e multiples of 9 except 9. So we remove {18}
x = x+1
9) When x = 10, we have to delete that elements from S which satisfy 0 == i mod 10 and i ≠ 10 i.e multiples of 10 except 10. So we remove {20}
x = x+1
Now x = 11, we break the while loop and the program is terminated.
So, after deleting the above elements, we are left with
{2, 3, 5, 7, 11, 13, 17, 19}
Pre-Assessment: Algorithms - Algorithm Structures:
Question 3:
Given the pseudocode fragment:
x := 2
count := 4
while (count > 0)
x := 2 * x
count := count - 1
End-while
What is the final value for x?
32
x = 2 * 2
x = 2 * 4
x = 2 * 8
x = 2 * 16
x = 32
Pre-Assessment: Algorithms - Analyzing Algorithms:
Question 4:
Function Sampler (Sequence Data)
Set Sample to an empty sequence
Set N to the length of Data
While N>=1
Append element N of Data to Sample
N:= N/2
Return Sample
What is the worst-case run time for Function Sampler?
O(log₂N)
Pre-Assessment: Algorithms - Analyzing Algorithms:
Question 5:
Given this algorithm:
Simple Sort
This algorithm sorts the elements of an array.
Input: numb, an array of n integers
Output: numb, in ascending order
for i = 1 to n
for j = 1 to n - i
if numb(j) > numb(j + 1)
temp = numb(j)
numb(j) = numb(j + 1)
numb(j + 1) = temp
end for
end for
What is the asymptotic worst-case complexity?
O(n²)
Pre-Assessment: Algorithms - Big-O Estimates:
Question 7:
Assume that the Sort(list L) function operates in O(nlogn) time, where n is the length of the list (of numbers.)
Variables L1, L2, and L3 are lists of real numbers, all of length n.
Given the following pseudocode function:
Function Sort3(L1, L2, L3)
K1 = Sort(L1)
For each element, E1, of L1,
Add E1 to each element of L2
K2 = Sort(L2)
For each element, E2, of L2
Add E2 to each element of L3
K3 = Sort(L3)
End-For
End-For
L = Append lists K3, K1, and K2
return L
Which function dominates the run time of Sort3(L1, L2, L3)?
O(n³logn)
Pre-Assessment: Algorithms - Big-O Estimates:
Question 8:
Which function is Θ(x³)?
4x³ + √x−1
Pre-Assessment: Algorithms - Big-O Estimates:
Question 9:
What is the big-O notation for the function
f(n) = n × log(n²) + 7n³ + 5n + 3?
O(n³)
Pre-Assessment: Counting and Advanced Counting Techniques - Advance Counting Techniques
Question 39:
An 11-person musical ensemble is on a stage with a tuba and a cello. Only 1 of the 11 can play both instruments, and exactly 4 can play neither instrument. The number of ensemble members who play only the cello equals the number who play only the tuba.
How many members of the 11-person ensemble play only the cello?
3
1 plays both instruments and 4 play neither therefore, out of 11 we remove these 5
so remaining there are 6 people
since the number of members who plays only cellp = the number who plays only tuba, we have the number of members who plays cello only = 3
Pre-Assessment: Counting and Advanced Counting Techniques - Advance Counting Techniques
Question 40:
How many people must be in a group to ensure that at least 2 individuals have the same first initial?
27
According to the given condition, each person is treated as pigeon like objects and the first initials of a person (a category of definite character) is pigeonhole, so the numbers of pigeonhole is 26 that and the number of people in the group is the pigeon that is needed to be found.
Let there are 26 people all have different first initials from A to Z.
Now, to have at least 2 people have the same first initial there is a need of minimum one person in the group, that is, there are 26+1=27 people.
Thus, the number of people in the group to ensure that at least 2 individuals have the same first initial is 27.
Pre-Assessment: Counting and Advanced Counting Techniques - Advance Counting Techniques
Question 41:
Set A has 8 elements, B has 10 elements, and their intersection has 6 elements. How many elements are in the union of these two sets?
12
10+8-6 = 12
Pre-Assessment: Counting and Advanced Counting Techniques - Counting by Bijections and Products of Sets
Question 30:
A club of 12 people would like to choose a person for each office of president, a vice president, and a secretary. How many different ways are there to select the officers so that only one person holds each office?
1320
12*11*10 = 1320
Pre-Assessment: Counting and Advanced Counting Techniques - Counting by Bijections and Products of Sets
Question 31:
A fair coin is flipped n times and the results recorded. How many different sequences of heads and tails are possible?
2ⁿ
The number of different sequences of heads and tails when a fair coin is flipped n times can be calculated using the formula 2ⁿ.
This is because for each flip, there are 2 possible outcomes (heads or tails), and since each flip is independent, we multiply the number of possibilities for each flip together.
Explanation:
The number of different sequences of heads and tails when a fair coin is flipped n times can be calculated using the formula 2ⁿ.
This is because for each flip, there are 2 possible outcomes (heads or tails), and since each flip is independent, we multiply the number of possibilities for each flip together.
Pre-Assessment: Counting and Advanced Counting Techniques - Counting by Bijections and Products of Sets
Question 32:
A mother, father, and their 3 children are having their picture taken. They will all be seated elbow-to-elbow on the living room couch, and the children will not be permitted to sit next to each other.
How many different arrangements are possible for the picture?
12
Number of permutations = n!/(n-r)
3!/(3-3)! = 6
So, there are 6 ways to arrange the three children in the remaining spaces.
Now, multiply the number of ways to arrange the parents (2 ways) by the number of ways to arrange the children (6 ways):
Total arrangements = 2 * 6 = 12
Pre-Assessment: Counting and Advanced Counting Techniques - Counting with Multisets
Question 35:
A grocery store stocks 1-gallon cartons of skim milk, 1% milk, 2% milk, and whole milk. A customer is asked to buy 10 gallons of milk. The customer needs to buy at least one carton of each type of milk.
How many different ways can the kinds of milk to buy be selected?
84
6 gallons of milk will remain after purchasing at least 1 carton of each type of milk, and from these 1 - gallons, 4 distinct varieties of milk must be selected.
The formula for the "Combinations with Repetition" is given as follows:
(r+n-1)! / r!(n-1)!
Where n is the number of objects to choose from,
r is the sample to be chosen.
In this case, n=4, and r=6.
The number of different ways is computed as follows:
(6+4-1)! / 6! * (4 -1)! = 84
Pre-Assessment: Counting and Advanced Counting Techniques - Counting with Multisets
Question 36:
Twenty people have volunteered for an experiment. Twelve of the volunteers are men and eight are women.
How many ways are there to select a group of five men and four women?
C(12,5) * C(8,4)
Pre-Assessment: Counting and Advanced Counting Techniques - Counting with Permutations and Combinations
Question 33:
How many ways can 7 soccer balls be divided among 3 coaches for practice?
36
( n+r-1 / (r-1) )
n=7
r=3
C(9,2) = 36
Pre-Assessment: Counting and Advanced Counting Techniques - Counting with Permutations and Combinations
Question 33:
How many ways can a club select a president, a vice president, a secretary, and a treasurer if the club consist of 12 people?
11,880
12*11*10*9
Pre-Assessment: Counting and Advanced Counting Techniques - Generating Permutations and Combinations
Question 37:
Which permutation of the set {1, 2, 3, 4, 5, 6} is first in lexicographic order?
(4, 6, 3, 2, 1, 5)
(4, 5, 2, 3, 6, 1)
(4, 5, 2, 3, 1, 6)
(4, 6, 5, 3, 2, 1)
(4, 5, 2, 3, 1, 6)
Pre-Assessment: Counting and Advanced Counting Techniques - Generating Permutations and Combinations
Question 38:
Using lexicographic order, which 4-tuple of {1, 2, 3, 4, 5, 6} fits in the blank of the inequality chain (3, 1 , 4, 1) < (4, 2, 3, 2) < _____________ < (5, 3, 3, 2)?
(3, 2, 3, 1)
(3, 3, 4, 3)
(4, 1, 3, 3)
(4, 2, 4, 1)
(4, 2, 4, 1)
Pre-Assessment: Discrete Probability - Conditional Probability and Bayes Theorem
Question 44:
Assume that a test for a disease gives a positive result for 1.5% of people who do not have the disease, but does not test negative if the person has the disease.
What is the probability that a person who tested positive has the disease, if 1% of people have the disease?
40%
In this case, we know the following:
P(disease) = 0.01 (1%)
Therefore, P(no disease) = 0.99 (1-1%)
P(+ve result | disease) = 1 (since the test does not test negative if the person has the disease)
P(+ve result | no disease) = 0.015 (since the test gives a positive result for 1.5% of people who do not have the disease)
Plug into Bayes Theorem
Pre-Assessment: Discrete Probability - Conditional Probability and Bayes Theorem
Question 45:
There are two coins, one fair and one biased. The biased coin comes up heads with a probability 0.8 and tails with a probability 0.2. One of the coins is selected at random and flipped ten times. The results of the coin flips are mutually independent. The result of the 10 flips is H, T, T, H, H, T, H, H, T, H.
What is the probability that the coin flipped was the biased coin? (Round to the nearest tenth.)
0.3 OR 30%
Explanation:
P(HHTTTHTHHT | B)=0.86 ×0.24
P(HHTTTHTHHT | F)=0.510
P(B)=P(F)=0.5
(0.8⁶ × 0.2⁴) × 0.5 / (0.8⁶ × 0.2⁴) × 0.5 + (0.5¹⁰) × 0.5
Pre-Assessment: Discrete Probability - Conditional Probability and Bayes Theorem
Question 46:
A life insurance company issues standard or preferred policies. Of the company's policyholders, 60% have standard policies and a probability of 0.01 of dying in the next year, and 40% have preferred policies and a probability of 0.08 of dying in the next year. A policyholder dies in the next year.
What is the conditional probability of the deceased having a preferred policy?
P(S) = 0.60, P(P) = 0.40,P(D|P) = 0.08, P(D|S) = 0.01, and the answer is 0.8421.
P(S)=0.60 (probability of having a standard policy)
P(P)=0.40 (probability of having a preferred policy)
P(D|P)=0.01 (probability of dying given a standard policy)
P(D|S)=0.08 (probability of dying given a preferred policy)
(0.08 × 0.40) / (0.08 × 0.40) + (0.60 ×0.01) = 0.8421
Pre-Assessment: Discrete Probability - Random Variables
Question 47:
Which formula is the expected value of the random variable Y ?
(upper limit)∑(index = lower limit),
∑(s∈Y), | Y (s) | p(s)
Pre-Assessment: Discrete Probability - Random Variables
Question 48:
A circle of radius 1 is inscribed in a square with side length 2 as shown in the diagram below:
If 1,000 points are selected randomly inside the square with all points equally likely to be selected, how many of those points are expected to lie inside the circle?
785
Length of the side of square= 2
The radius of inscribed circle= 1
Area of square= (side)² = 2²=4
Area of circle = 3.14 × Radius² = 3.14 × 1² = 3.14
If there are total 1,000 points in the circle ,then expected points to fall inside the circle are:
No. of points in circle= (Total points /area of square ) × area of circle
No. of points in circle= (1,000 / 4) ×3.14=785
Pre-Assessment: Discrete Probability - Random Variables
Question 49:
There are four different colored balls in a bag. There is equal probability of selecting the red, black, green, or blue ball. What is the expected value of getting a green ball out of 20 experiments with replacement?
5
20 × .25
Pre-Assessment: Discrete Probability - Introduction to Probability
Question 42:
A company has three active projects: Domino, Falcon, and Giant. There are 19 employees charging time to Domino, 16 to Falcon, and 15 to Giant. Those totals include 8 employees charging both Domino and Falcon, 6 charging both Falcon and Giant, and 7 charging both Giant and Domino. Included in those subtotals is the 4-person IT team, all of whose members charge all three projects.
How many employees are working on the projects?
33
Total employee = 19 + 16 + 15 = 20
Charging employees = 8 + 7 + 6 = 21
Duplicate charges = 21 - 4 = 17
Actually working employees = 50 - 17 = 33
Pre-Assessment: Discrete Probability - Introduction to Probability
Question 43:
A random experiment consists of tossing a fair six-sided die repeatedly. How many tosses are required to be certain that the probability that at least one '6' appears is greater than or equal to 1/2?
4
The probability of not getting a 6 in one toss is P(not 6)=56
Now, applying this value into the expression we found in step(1),
⇒1−(P(not 6))n≥1/2
⇒1−(5/6)n≥1/2
⇒−(5/6)n≥−1/2
⇒(5/6)n≤1/2
⇒ln(5/6)n≤ ln(12)
⇒n×ln(5/6)≤ ln(1/2)
⇒n≤ ln(1/2)ln(5/6) = 3.80 round to 4
Pre-Assessment: Number Theory and Cryptography - Mathematical Foundations of Encryption
Question 18:
An encryption scheme uses the numerical position of a letter in the alphabet to encrypt characters, e.g., A=1, D=4, Z=26, etc., and spaces are ignored. What is the encoding of "HAPPY BIRTHDAY" using this technique?
8116162529182084125
Pre-Assessment: Number Theory and Cryptography - Mathematical Foundations of Encryption
Question 19:
An individual has chosen the public key of N = 187 = 11 x 17 and e = 3.
What is the private key using RSA encryption?
107
To find the RSA private key d, you calculate the modular inverse of the public exponent e with respect to (p−1)(q−1), where p and q are the prime factors of N. Here, N=187 is factored into p=11 and q=17. Thus, ϕ(N)=(11−1)(17−1)=160. The private key d satisfies 3d≡1mod160. Using the Extended Euclidean Algorithm, we find d=107, which is the modular inverse of 3 modulo 160.
Pre-Assessment: Number Theory and Cryptography - Mathematical Foundations of Encryption
Question 20:
An individual has chosen a public key of N = 391 = 17 × 23 and e = 7. What is the private key using RSA encryption?
151
Public key (N, e)
N = 391
e = 7
Factorize N into primes:
p = 17
q = 23
Calculate phi(N):
(N)=(p−1)(q−1)
(N)=(17−1)(23−1)
(N)=16×22
(N)=352
Find d such that:
e×d≡1(modδ(N))
7×d≡1(mod352)
Solve this modular equation:
7×151≡1(mod352)
Therefore, the private key is 151
Pre-Assessment: Number Theory and Cryptography - Divisibility and Modular Arithmetic
Question 10:
What is the ones digit of the number 3⁹⁰²?
9
1. First Iteration: 31 mod 10:
3¹ mod 10=3
2. Second Iteration: 3² mod 10:
3. Third Iteration: 3³ mod 10:
3³ mod 10=7
4. Fourth Iteration: 3⁴ mod 10:
3⁴ mod 10=1
Now, since the pattern repeats every 4 powers, let's find the remainder when 902 is divided by 4 :902=225×4+2
3⁹⁰² mod 10=(34)²²⁵×3² mod 10
=(1)²⁵⁵×3² mod 10
=9
So, the last digit of 3⁹⁰² is the same as the second power in the cycle, which is 9.
Pre-Assessment: Number Theory and Cryptography - Divisibility and Modular Arithmetic
Question 11:
N is an integer between 0 and 9. For how many values of N does [123,3N2] = [0] mod 8, where 123,3N2 is a six-digit number?
3
n = 0-9
The number is 123,302 . This is not divisible by 8.
If N=1;
The number is 123,312 . This is divisible by 8.
If N=2;
The number is 123,322. This is not divisible by 8.
If N=3;
The number is 123,332. This is not divisible by 8.
If N=4;
The number is 123,342. This is not divisible by 8.
If N=5;
The number is 123,352. This is divisible by 8.
If N=6;
The number is 123,362. This is not divisible by 8.
If N=7;
The number is 123,372. This is not divisible by 8.
If N=8;
The number is 123,382. This is not divisible by 8.
If N=9;
The number is 123,392.This is divisible by 8.
Pre-Assessment: Number Theory and Cryptography - Fast Exponentiation Algorithms
Question 16:
Let N = 12 = 2² + 2³.
Given that M² ≡ 51 (mod 59), what is M¹² (mod 59)?
7
M2≅51(mod59)(1)
Now we have to calculate
M¹²(mod59)
Then by equation(1),
M²=51(mod59)
Squaring both sides,
M⁴=(51)²(mod59)
M⁴=2,601(mod59)
M⁴=(59×44+5)(mod59)
M⁴=5(mod59)
Now taking cube both sides,
M¹²=5³(mod59)
M¹²(mod59)=125(mod59)
M¹²(mod59)=(2×59+7)(mod59)
M¹²(mod59)=7(mod59)
Hence we can conclude that,
M¹²(mod59)=7
Explanation:
We used the theory of modulo.
Pre-Assessment: Number Theory and Cryptography - Fast Exponentiation Algorithms
Question 17:
The binary representation of 21 is 10101. What is 17²¹ mod n rewritten using the given binary expression?
(((17¹⁶)×(17⁴)+17)modn)
1) To calculate (17²¹modn) using the binary exponentiation method, we can break down the exponent 21 in its binary representation (21=10,101) in binary.
The binary exponentiation method involves using the binary representation of the exponent to efficiently calculate the result by squaring and multiplying.
1) Start with the base number (17).
2) Initialize a variable to keep track of the result, initially set to 1.
3) For each bit in the binary representation of the exponent:
i) If the current bit is 1, multiply the result by the current base number.
ii) Square the base number for the next iteration.
4) Take the result modulo (n) to get the final answer.
The binary representation of (21) is (10101), we need to perform the following multiplications and squarings
Explanation:
17¹:Multiply by 17
17²:Square the previous result
17⁴:Square the previous result
17⁸:Square the previous result
17¹⁶:Square the previous result
Then, we can apply the binary exponentiation method using the binary representation of 21
17²¹modn=((17¹⁶)×(17⁴)+17)modn
So that, the correct option is d) (((17¹⁶)×(17⁴)+17)modn)
This method allows us to efficiently calculate large exponentiations modulo (n) using the binary representation of the exponent, reducing the number of multiplications and squarings needed.
Pre-Assessment: Number Theory and Cryptography - Number Representation in Other Bases
Question 14:
What is the decimal expansion of (10011001)₂?
153
Pre-Assessment: Number Theory and Cryptography - Number Representation in Other Bases
Question 15:
What is the minimum number of bits required for the binary representation of a number greater than 32?
6
Explanation: To determine the minimum number of bits required, we need to find the smallest power of 2 that is greater than 32.
The smallest power of 2 greater than 32 is 2⁶=64.
Since 2⁶ requires 6 bits to represent in binary, any number greater than 32 will also require at least 6 bits for its binary representation.
Pre-Assessment: Number Theory and Cryptography - Prime Factorization, GCD and Euclid's Algorithm
Question 12:
Which set contains the multiplicative inverse of 13 mod 33?
{4, 12, 20, 28}
To find the inverse of 13 modulo 33 , we need to find a number x such that (13 × x)mod33 equals 1. In other words, we are looking for a number x such that (13 × x) divided by 33 leaves a remainder of 1.To solve this, we can use the Extended Euclidean Algorithm.
Step 1: We start with the equation 33=13×2+7.
Step 2: Then, we have 13=7×1+6.
Step 3: Next, we have 7=6×1+1.
Step 4: Rearranging the equation 1=7−6×1 , we substitute previous equations to express 1 in terms of 33 and 13:1=7−6×(13−7×1)=7×2−6×13.
Step 5: Continuing to substitute, we express 1 in terms of 33 and 13:1=(33−13×2)×2−6×13=33×2−13×5. Comparing this equation with the original equation we wanted to solve, we can see that x=−5 satisfies the requirement. However, to ensure the inverse is positive, we can add a multiple of the modulus to x. In this case, we can add 33 to -5 to get the positive inverse:x=−5+33=28 . Therefore, the inverse of 13 modulo 33 is 28.
Therefore the set that contains inverse of 13mod 33 is
{4, 12, 20, 28}
Pre-Assessment: Number Theory and Cryptography - Prime Factorization, GCD and Euclid's Algorithm
Question 13:
What is the sequence of remainders obtained when using Euclid's algorithm to compute the greatest common divisor (GCD) of 178 and 20?
18 2 0
In Euclid's algorithm, we use a repeated application of Division algorithm.
Apply Euclid's algorithm to a=178 and b=20, we get
178=20×8+1820=18×1+218=2×9+0
Here the last non-zero remainder in the Euclid's algorithm is equal to 2.
Explanation:
The last non-zero remainder in the euclidean algorithm gives the GCD of two numbers
The greatest common divisor (GCD) of 178 and 20 is equal to GCD(178,20)=2.
Pre-Assessment: Recursion and Induction - Induction Methods
Question 23:
Which expression is equivalent to the given expression? 6∑i=−3, (2i−3)
Now we have ...
∑i=−36(2i−3)=[2(−3)−3]+∑i=−25(2i−3)+[2(6)−3]⇒∑i=−36(2i−3)=[−6−3]+∑i=−25(2i−3)+[12−3]⇒∑i=−36(2i−3)=−9+∑i=−25(2i−3)+9⇒∑i=−36(2i−3)=∑i=−25(2i−3)
This is required result...
Answer
So the final result is....
∑i=−36(2i−3)=∑i=−25(2i−3)
so option ist is correct
Pre-Assessment: Recursion and Induction - Induction Methods
Question 24:
In the proof for the sum of squares, the inductive hypothesis for any natural number is: P(n): 0² + 1² + 2² + ... + n² = n(n + 1)(2n + 1)/6, n≥0. If n = 0, then the left-hand side of P(0) = 0² = 0, and right-hand side of P(0) = 0 × (0 + 1)(2 × 0 + 1)/6 = 0 . What is the right-hand side of P(n+1)?
(n + 1)(n + 2)(2n + 3)/6
The right-hand side of P(n+1) can be found by replacing n with n+1 in the formula for the right-hand side of P(n):
P(n+1)=(n+1)((n+1)+1)(2(n+1)+1)6
Step 2
Simplifying this expression gives:
P(n+1)=(n+1)(n+2)(2n+3)6
So, the right-hand side of P(n+1) is (n+1)(n+2)(2n+3)6.
Explanation:
This is the right-hand side of the inductive step for P(n+1) in the sum of squares proof.
Answer
The right-hand side of P(n+1) is (n + 1)(n + 2)(2n + 3)/6
Pre-Assessment: Recursion and Induction - Induction Methods
Question 25:
In the inductive proof of: 4+9+14+19+...+(5n+4)=n2(3+5n)4+9+14+19+...+(5�+4)=�2(3+5�) The inductive hypothesis is that for any n = k, 4+9+14+19+...+(5k+4)=k2(3+5k)4+9+14+19+...+(5�+4)=�2(3+5�) What must be proven assuming the inductive hypothesis is true?
4+9+14+19+...+(5k+4)+(5(k+1)+4)=k+12(3+5(k+1))4+9+14+19+...+(5�+4)+(5(�+1)+4)=�+12(3+5(�+1))
No clue
Pre-Assessment: Recursion and Induction - Recurrence Relations
Question 21:
Given the recursive algorithm in this pseudocode: RTC(n) Input: A nonnegative integer, n
Output: A numerator or denominator (depending on parity of n) in an approximation of
If n < 3
Return (n + 1)
If n >= 3
t: = RTC(n - 1)
If n is odd
s:= RTC(n - 2)
Return (s + t)
If n is even
r:= RTC(n - 3)
Return (r + t)
If n is even
print 'Your approximation is ' , RTC(n) , '/' , RTC(n - 1) , '.'
What is the output for the algorithm if the input n is 6?
Your approximation is 17/12.
RTC calls (6)
t = RTC(5), invoking
t = RTC(4), invoking
t = RTC(3), invoking
RTC(2) = t
In this case, RTC(2) returns n+1 as n<3, that is, 2+1 = 3 to t of RTC(3), meaning RTC(2)=3.
where t = 3 in RTC(3)
Since s = RTC(3-2) = RTC(1), 3 is odd, return 2 to s.
s = 2.
Return s+t = 2+3=5 to RTC(4)'s t, resulting in RTC(3)=5.
RTC(4-3) = RTC(1) returns 2 to r when 4 is even.
RTC(4) returns to t of RTC(5), i.e., RTC(4) = 7, t + r = 5+2 = 7.
RTC-5
declares RTC(5-2) to be odd at 5 RTC(3) is kept at 5 in s.
return to t of RTS(6), RTC(6) = 12; that is, 7+5 = 12.
Even number six calls RTS(3), storing the result in r = 5.
Thus, it yields t+r, or 12+5 = 17, or RTC(6) = 17.
RTC(6)/RTC(5) is therefore 17/12.
Explanation:
Prints 'Your approximation is ', RTC(n), '/', RTC(n - 1), '.' if n is even.
This algorithm uses the parity of the input n to recursively compute an approximation. It prints the approximation in the given format if n is even.
Pre-Assessment: Recursion and Induction - Recurrence Relations
Question 22:
The recurrence relation is given by aₙ=aₙ−₁+n with initial term a₀=4. What is the value of a₅?
19
Step 1
using the given recurrence relation an=an−1+n with the initial term
a0=4. a₁=a₀+1=4+1=5
Here, we add 1 to the previous term a0 (which is 4) to get a₁.
a₂=a₁+2=5+2=7
Similarly, we add 2 to the previous term a1 (which is 5) to get a₂.
a₃=a₂+3=7+3=10
Again, we add 3 to the previous term a2 (which is 7) to get a3.
a4=a3+4=10+4=14
Step 2
We add 4 to the previous term a3 (which is 10) to get a4.
a5=a4+5=14+5=19
Finally, we add 5 to the previous term a4 (which is 14) to get a5.
So, the value of a5 is 19 , which is the result of applying the recurrence relation repeatedly with the given initial term.
Explanation:
The concept used here is called "recurrence relation." A recurrence relation is a mathematical relationship that defines a sequence of terms based on previous terms in the sequence. In this case, the recurrence relation is given as:
aₙ=aₙ−₁+n
Where:
an represents the nth term in the sequence.
an−1 represents the previous term (n-1th term) in the sequence.
n is the value used to calculate the current term by adding it to the previous term.
Answer
The value of a5 is 19 , which is the result of applying the recurrence relation repeatedly with the given initial term.
Pre-Assessment: Recursion and Induction - Recursive Structures
Question 26:
Given this algorithm written in pseudocode:
Algo(n)
Input: A positive integer n
Output: Answer, Algo(n)
If n = 1
Answer = 3
Else
Answer = 3 × Algo(n-1)
End if
What is Algo(4)?
81
Pre-Assessment: Recursion and Induction - Recursive Structures
Question 27:
Given this pseudocode:
input: sequence of numbers ak
k, length of sequence
answer := a₁
for i = 2 to k
if (ai > answer), then answer = ai
End-for
What is the value of answer for the sequence {-1, 4, -7, 10, 2} with k = 5?
10
Pre-Assessment: Recursion and Induction - Simple Recurrence Relations
Question 28:
Given the characteristic equation for a linear homogeneous recurrence relation, fₙ:
(x + 10)(x - 12) = 0
The initial values given are f₀ = 0 and f₁ = 1.
What is the closed form solution for fₙ?
The closed-form answer for the expression fₙ is −12/2 × (−10)ⁿ + 12/2 × 12ⁿ.
Pre-Assessment: Recursion and Induction - Simple Recurrence Relations
Question 29:
Suppose aₙ₊₁ = 3aₙ - 2aₙ-1 and a₀ = 1, a₁ = 2. What is an expressed as a function of n?
2ⁿ