What is the order of the following algorithm:
procedure Func1(m,n)
{
while (m > 0)
{
t = n mod m;
n = m;
m = t;
}
}
(Select the answer from the following options and prove your choice):
a) theta (ln m)
b) m^2
c) n^m
d) m^n
What is the order of the following algorithm: procedure Func1(m,n) { while (m > 0) {...
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-
(V). Given the following algorithm, answer relevant questions. Algorithm 1 An algorithm 1: procedure WHATISTHIS(21,22,...,n: a list of n integers) for i = 2 to n do c= j=i-1 while (j > 0) do if ra; then break end if 4j+1 = a; j= j-1 end while j+1 = 1 end for 14: return 0.02. 1, 15: end procedure Answer the following questions: (1) Run the algorithm with input (41, 02, 03, 04) = (3, 0, 1,6). Record the values...
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.
Discrete Math Give a big-Theta estimate for the number of additions in the following algorithm a) procedure f (n: integer) bar = 0; for i = 1 to n^3 for j = 1 to n^2 bar = bar + i + j return bar b) Consider the procedure T given below. procedure T (n: positive integer) if n = 1 return 2 for i = 1 to n^3 x = x + x + x return T(/4) + T(/4) +...
1) Which Design Technique was used to produce Kruskal's Algorithm? (Select the answer from the following options and prove your choice): a) Dynamic Programming b) Greedy c) Divide and Conquer d) Linear Programming PLEASE EXPLAIN IT IN DETAIL
Algorithm performance Give the order of magnitude Theta () for the following algorithm. Explain why your answer is correct. GET VALUES for A_1, A_2, .. ., A_n, and B_1, B_2, .. ., B_n Get value of n i = 1/* set i equal to 1 */DO WHILE (i lessthanorequalto n)/* for each of the n values in A */j = 1/* set j equal to 1 */DO WHILE (j lessthanorequalto n)/* Do n times *1 IF Ai = Bj THEN...
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...
Copy of Consider the following algorithm: i+2 while (x mod i)=0 do iti+1 Now suppose x is an element from the set {n EN|2sn s50). What is the worst-case number of comparisons that this algorithm will perform? O O O O O O
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...
The following algorithm (Rosen pg. 363) is a recursive version of linear search, which has access to a global list of distinct integers a_1, a_2,..., a_n. procedure search(i, j, x : i,j, x integers, 1 < i < j < n) if a_i = x then return i else if i = j then 4. return 0 else return search(i + 1, j, x) Prove that this algorithm correctly solves the searching problem when called with parameters i = 1...