Question

Consider the following algorithm. i ← 2 while (N mod i) ≠ 0 do i ←...

Consider the following algorithm. i ← 2 while (N mod i) ≠ 0 do i ← i + 1 Suppose instead that N is in {2, 3, 4, 5, 6, 7, 8, 9}, and all these values are equally likely. Find the average-case number of "N mod i" operations made by this algorithm.

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider the RSA algorithm with n=33 and E=7. 1. Encode the message 8. 2. Find the...
Consider the RSA algorithm with n=33 and E=7. 1. Encode the message 8. 2. Find the value of D. 3. Decode the message 9. Consider the RSA algorithm with n=65 and E=5. 4. Encode the message 8. 5. Find the value of D. 6. Decode the message 2.
Given the following algorithm, matching each statement to the correct sequence for complexity analysis. procedure Alg3(A):...
Given the following algorithm, matching each statement to the correct sequence for complexity analysis. procedure Alg3(A): A is a list of n integers 1 for i = 1 to n-1 do 2   x=aix=ai 3 j = i − 1 4 while (j ≥≥ 0) do 5 if x≥ajx≥aj then 6 break 7 end if 8   aj+1=ajaj+1=aj 9 j = j − 1 a end while b   aj+1=xaj+1=x c end for d return A The complexity of this algorithm is O(n2)O(n2)...
Design a recursive divide-and-conquer algorithm A(n) that takes an integer input n ≥ 0, and returns...
Design a recursive divide-and-conquer algorithm A(n) that takes an integer input n ≥ 0, and returns the total number of 1’s in n’s binary representation. Note that the input is n, not its binary representation. For example, A(9) should return 2 as 9’s binary representation is 1001, while A(7) should return 3 since 7 is 111 in binary. Note that your algorithm should have a running time of O(log n). Justify your answer. You need to do the following: (1)...
First, understand the Selection-sort algorithm below: Selection-sort(A: Array [1..n] of numbers) 1       for i=n down to...
First, understand the Selection-sort algorithm below: Selection-sort(A: Array [1..n] of numbers) 1       for i=n down to 2 2                position=i 3                for j=1 to (i–1) 4                          if A[j]>A[position] then position=j 5                if position ≠ i then 6                          temp=A[i] 7                          A[i]=A[position] 8                          A[position]=temp (4 points) If input A=[12,5,11,6,10,7,9,8], what will A be after the 3rd iteration of the outermost for loop of the Selection-sort algorithm completes? A=[__, __, __, __, __, __, __, __] (8 points) Modify the algorithm to solve the...
Consider the following recursive algorithm. Algorithm Test (T[0..n − 1]) //Input: An array T[0..n − 1]...
Consider the following recursive algorithm. Algorithm Test (T[0..n − 1]) //Input: An array T[0..n − 1] of real numbers if n = 1 return T[0] else temp ← Test (T[0..n − 2]) if temp ≥ T[n − 1] return temp else return T[n − 1] a. What does this algorithm compute? b. Set up a recurrence relation for the algorithm’s basic operation count and solve it.
Answer the following question: 1. a. Use an affine cipher x 7→ 3x + 1 (mod...
Answer the following question: 1. a. Use an affine cipher x 7→ 3x + 1 (mod 26) to encode “Baltimore”. b. Let a and b be integers. What does it mean to say a divides b? Provide a precise definition and include the proper notation. c. Let a, b, c, and n be integers with n 6= 0. Suppose that a ≡ b (mod n) and b ≡ c (mod n). Prove that a ≡ c (mod n). d. Use...
5. (a) Find the values of 2k mod 9 where k = 1, 2, 3, 4,...
5. (a) Find the values of 2k mod 9 where k = 1, 2, 3, 4, 5, 6, 7, 8, 9. (b) Find the remainder of 2271 when this number is divided by 9. (c) Find the remainder of 2271 when this number is divided by 5. PLEASE GIVE RIGHT ANSWERS AND GOOD DETAILS ON HOW TO GET THE ANSWERS THE ANSWERS I GOT YESTERDAY FROM YOUR GUYS WERE WRONG!!!
The smallest positive solution of the congruence ax ≡ 0( mod n) is called the additive...
The smallest positive solution of the congruence ax ≡ 0( mod n) is called the additive order of a modulo n. Find the additive orders of each of the following elements by solving the appropriate congruences: (abstract algebra) (a) 20 modulo 28 (b) 8 modulo 15 (c) 7 modulo 11 (d) 9 modulo 15
Consider the following insertion sort algorithm. void insertion_sort(element a[], int n) // Put a[0]..a[n-1] into ascending...
Consider the following insertion sort algorithm. void insertion_sort(element a[], int n) // Put a[0]..a[n-1] into ascending order by insertion sort. { for (int k = 1; k < n; k++) { // At this point, a[0]..a[k-1] are already in order. // Insert a[k] where it belongs among a[0]..a[k]. You need to write code for this insertion as the body of the for-k loop. }//endfor k } a) Write the code for the body of the for-k loop to complete the...
design an efficient algorithm that, on input a set of n real numbers {x1, . ....
design an efficient algorithm that, on input a set of n real numbers {x1, . . . , xn}, outputs all distinct numbers in the set. For example, if your input is {5, 10, 9, 10, 8, 5, 12, 11, 12, 9, 7, 6, 8, 5}, then you should output {5, 10, 9, 8, 11, 12, 7, 6} (any ordering of these number is acceptable).
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT