2. Find 11644 mod 645 Use the following algorithm and show work!
procedure modularExponentiation(b: integer, n =
(ak-1ak-2...a1a0)2, m:positive integer)
x:= 1
power := b mod m
for i = 0 to k-1
If ai = 1 then x:= (x⋅power) mod m
power := (power⋅power) mod m
return x ( x equals bn mod m)
Note: in this example m = 645, ai is the binary expansion of 644, b
is 11.
2. Find 11644 mod 645 Use the following algorithm and show work! procedure modularExponentiation(b: integer, n...
Let m be a positive integer. Show that a mod m - b mod m t a - b (mod m) Drag the necessary statements and drop them into the appropriate blank to build your proof (mod m Dag the mecesary eemnes a ohem int the approprite Proof method: Proof assumptions), at-qm + Proof by contradiction aaandh mam it Implication(s) and deduction(s) resulting from the assumption(s): a mk + bmk Hqm tr a-(k + q)m+ r Conclusion(s) from implications and...
What is the time-complexity of the algorithm abc? Procedure abc(n: integer) s := 0 i :=1 while i ≤ n s := s+1 i := 2*i return s consider the following algorithm: Procedure foo(n: integer) m := 1 for i := 1 to n for j :=1 to i2m:=m*1 return m c.) Find a formula that describes the number of operations the algorithm foo takes for every input n? d.)Express the running time complexity of foo using big-O/big-
8. [10 points) Consider the following algorithm procedure Algorithm(: integer, n: positive integer; 81,...a s integers with vhilei<r print (l, r, mı, arn, 》 if z > am then 1:= m + 1 if za then anstwer-1 return answer 18 and the (a) Assume that this algorithm receives as input the numbersz-32 and corresponding sequence of integers 2 | 3 1 1 4151617| 8| 9 | 10 İ 11 İ 12 | 13 | 14|15 | 16 | 17 |...
9. [10 points) Consider the following algorithm: procedure Algorithm(n: positive integer; ddd: distinet integers) for k:=1 to n-1 for 1-1 to n-k print(k, I, di,da...-1,dn) if ds dti then interchange dy and d (a) Assume that this algorithm receives as input the integer n 6 and the input sequence 하하하하하하, Miss ^-ruteae rehen i12|3141516 Fill out the table below: ds ds (b) Assume that the algorithm receives the same input values as in part a). Once the algorithm finishes, what...
4. The following algorithm step 1: 20 := r; j :=0 step 2: while x; # 0, do d; := remainder of integer divide x;/2 Xj+1 := quotient of integer divide x;/2 j:= + 1 end while can be used to convert a positive decimal integer x to its binary equivalent, x = (anan-1.0190)2. Implement the algorithm (write a computer program) and apply it to convert the following integers to their binary equivalents. (a) 56 (b) 1543 (The Matlab library...
1 1 point Consider the following algorithm for factoring an integer N provided as input (in binary): For i = 2 to [VN.17 i divides N, then output (i, N/). Which of the following statements is true? This algorithm is correct, but it runs in exponential time. This algorithm is not correct, because it will sometimes fail to find a factorization of Neven if N is composite This algorithm runs in sub-linear time, and always factors N it Nis composite...
17. Consider the following algorithm: procedure Algorithm(n: positive integer; di,d2.. ,dn: distinct integers) for 1 to n-1 for 1 to n-k if ddi+ then interchange di and di+ print(k, I, d,ddn-1, dn) (a) |3 points Assume that this algorithm receives as input the integer-6 and the corresponding input sequence 41 36 27 31 17 20 Fill out the table below ds (b) 1 point Assume that the algorithm receives the same input values as in part a). Once the algo-...
(a) Design an algorithm that reveals some secret integer number from the set {1, 2, ... , n} by guessing random numbers within the given range until the secret number has been guessed. Numbers should be replaced after being guessed such that it is possible to guess 2 and then 2 again, assuming 2 is in the given range. The algorithm should return both the secret number as well as the number of guesses taken. (b) If possible, calculate the...
Write a simple Python program to find the day for the given date. The procedure to find the day of the week is as follows: F = (K + (13 * m – 1) mod 5 + D + D mod 4 + C mod 4 – 2 * C ) mod 7 where, K : day of the month m : month number D : remainder when year divided by 100 C : quotient when year is divided...
Search for 4 in the sequence {3,5,7,8,9,12,21,25}, by working through each step of the algorithm given below. Specify the values of i, j, m and am in each step. procedure binary search (x: integer, a1,a2,...,an: increasing integers) i := 1 {i is left endpoint of search interval } j := n {j is right endpoint of search interval } while i < j m := b(i + j)/2c if x > am then i := m + 1 else j...