Concept explainers
Question 1:
a) i) Give an inductive formula for the sum of the first n odd numbers:
1 + 3 + 5 + ... + 2n -1
Show your induction process.
ii) Use the proof by mathematical induction to prove the correctness of your
inductive formula in i) above.
...............................................................................................................................
b) The following C++ program segment computes C = A * B, where A is an “m” by “n”
matrix, B is an “n” by “r” matrix and C is an “m” by “r” matrix.
for (long int i = 0; i < m; i++)
for (long int j = 0; j < r; j++)
{
long double Sum = 0;
for (long int k = 0; k < n; k++)
Sum = Sum + A[i][k] * B[k][j];
C[i][j] = Sum;
}
How many times does the code iterate in computing
i) Sum?
ii) The j column of C, i.e. C[i][j] for a fixed i and j = 1, 2, ,3, ..., r?
th
iii) The complete matrix C?
......................................................................................................
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- 1 1 correct 1 1 correct 8 8 correct 80 370 8 correct 370 At least one of the answers above is NOT correct. (1 point) Fermat's "Little" Theorem states that whenver n is prime and a is an integer, an n-1 = 1 mod n 431 and n = 491, then efficiently compute a) If a = 431490 = 1 mod 491 b) If a = 204 and n = : 233, then efficiently compute . 204 204231 = 1 mod 233 Use the Extended Euclidean Algorithm to compute 204-¹ = 1 8 Then 2042318 c) If a mod 233. mod 233. = 807 and n = 881, then efficiently compute 807882 = 370 mod 881 incorrectarrow_forward#2arrow_forwardHELLP The statement is false is equivalent to its negation is true by giving an example . The negation is: ∃x in D such that P(x) ∧ ~Q(x) The above would be used via: proof by counterexample proof by exhaustion proof by manipulation proof by inductionarrow_forward
- (a) In the binary search algorithm, what are the four cases you have to consider at each iteration and what do you have to do in each case?arrow_forward6. Recursive Algorithms i. Give a recursive algorithm (not a formula!) for finding na where n is a positive integer and a is a real number. Prove that your algorithm is correct.arrow_forward) Translate the following argument into the language of PL and show it is valid by giving a derivation. Every planet except Earth is LIFELESS1. Therefore, given any distinct two planets, at least one of them is lifeless. (UD: Planets)arrow_forward
- (3) (a) A fair coin is flipped, if it lands on the head side, one dice is rolled and X is the resulted number, if it lands on the tail side, two dice are rolled and X is the resulted sum. Calculate E[X] and V[X]. Write a computer program and carry out a simulation to verify your answers. (b*) A person starts walking home from a bar towards his home. The distance is n blocks. Every hour he either manages to walk one block towards home, or gets confused and picks up a cab back to the bar (each with probability 1/2). At any point, if he is at the bar, he always moves ahead one block. What is the expected time it takes him to get home? (c) Write a computer program' and carry out a simulation to verify your answer. (If you have trouble with part (b), do the computer simulation and formulate a conjecture of the answer for partial credits.)arrow_forwardPLease give algorithm and explanation.arrow_forward2. If n is a positive integer, then n4 - n is divisible by 4. [Proof of Exhaustion]arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education