I NEED HELP BADLY PLEASE. THANK YOU
The following DivisionAlgorithm computes q and r for m > 0
and n > 0.
{Input: integers m > 0 and n > 0.}
{Output: integers q and r where m.q + r = n and 0 < r < m.}
Begin
q := 0
r := n while r > m do
q := q + 1
r := r – m return q and r End
Revise this algorithm to work for m > 0 and n in Z. Test your
revised routine using the following inputs (a) m = 5, n = 23 (b) m=
5, n = -23
Solution: Modified algorithm:
Begin
q:=0
r:=n
While (|r|>m ) do
if (n<0)
q=q-1
r=r+m
else
q=q+1
r=r-m
return q & r
a)For m=5 , n=23;
q=0 ; r=23 as 23>5 and n>0
q=q+1=0+1=1 and r=r-m=23-5=18 (r>m):
q=2 and r=13 (r>m)
q=3 and r=8 (r>m)
q=4 and r=3 (r<m)
23=5*4+3;
b)For m=5 , n=-23;
q=0 ; r=-23 as |-23|= 23>5 and n<0
q=q-1=0-1=-1 and r=r+m=-23+5=-18 (|r|>m):
q=-2 and |r|=-13 (|r|>m)
q=-3 and |r|=-8 (|r|>m)
q=-4 and |r|=-3 (|r|<m)
q=-5 and |r|=2
q=-5 and r=2
-23=5*-5+2;
I NEED HELP BADLY PLEASE. THANK YOU The following DivisionAlgorithm computes q and r for m...
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 |...
I NEED A MATHEMATICAL ALGORITHM FOR A CEASER CHYPER I CREATED. PLEASE HELP ME...THANK YOU! THE SINGLE-DIGIT KEY IS 14 THE PHRASE IS "GOOD MORNING PROFESSOR" THE CYPHER IS UCCR ACFBWBU DFCTSGGCF I DON'T KNOW HOW TO CREATE THE ALGORITHM AND IT CANNOT BE COMPUTER GENERATED. a. Develop a Caesar cipher-type encryption algorithm with a little more complexity in it. For example, the algorithm could alternatively shift the cleartext letters positive and negative by the amount of the key value....
Need help part B and C please. Thank you . CDA3201·Intro to Logic Desig Lab Assignment Name: Grade: 20 5) 120] At right is the state dingram for a Moore sequential 1 01.10 АО circuit which monitors two inputs XiXo. When the two inputs XiXo are 00, the output Z toggles at every clock When the two inputs XiXo are 11, the output Z toggles at every other clock. When the two inputs XiXo are different, the output Z holds...
need help with #1 thank you! EXERCISES Section 1.1 (Note: Solutions to odd-numbered exercises are given in the back of the book.) 1. Write an algorithm that computes the sum of the first n terms of the series 2. Write an algorithm that finds the smallest element among a, b, and c 3. Write an algorithm that finds the smallest element in the sequence s, s S, of n dis- tinct numbers. The input is the sequence, s, and the...
PYTHON I need help with this Python problem, please follow all the rules! Please help! THANK YOU! Bonus Question Implement an efficient algorithm (Python code) for finding the 11th largest element in a list of size n. Assume that n will be greater than 11. det find 11th largest numberlissy Given, lissy, a list of n integers, the above function will return the 11th largest integer from lissy You can assume that length of lissy will be greater than 11....
urgent L. Consider the following pseudocode for finding binomial coefficients: Binom(n, r) Input: integers n and r Output: n choose r if r-0 or r-n thern return 1 end else return Binom(n-1, r-1) Binom(n-1, r); end running time of this algorithm. Prove your bound for the upper bound. (5 points) Rewrite the above algorithm so that it is efficient. (You have 2 choices!) Analyze the worst case time of your new algorithm. (5 points) Find the edit distance between "SPOKE...
I need help with this in JAVA. please help me. Thank you. In this project. you are given a unimodal array of n integer and your task is to find the maximum integer in the array in theta(logn) time. An unimodal array of integers is an array with entries that monotonically increase up to the maximum integer value and then monotonically decrease for the rest of the array. For example: (2, 5, 8, 9, 12, 15, 21, 17, 10, 4)...
Consider the following: Algorithm 1 Smallest (A,q,r) Precondition: A[ q, ... , r] is an array of integers q ≤ r and q,r ∈ N. Postcondition: Returns the smallest element of A[q, ... , r]. 1: function Smallest (A , q , r) 2: if q = r then 3: return A[q] 4: else 5: mid <--- [q+r/2] 6: return min (Smallest(A, q, mid), Smallest (A, mid + 1, r)) 7: end if 8: end function (a) Write a recurrence...
I need you guys help with my Java Class( use netbean if you can, thank a lot ). Please help me out, I may need full working code Question: An array A contains n−1 unique integers in the range [0,n−1], that is, there is one number from this range that is not in A. Design an O(n)-time algorithm for finding that number. You are only allowed to use O(1) additional space besides the array A itself. DO NOT SORT THE...
Need help with this question. Thank you :) (6) (a) Consider the following graph P R U T (i) What are the degrees of the vertices in the graph? (ii) Does the graph have a closed Euler trail? If so, give an example of a closed Euler trail in the graph. If not, explain why no closed Euler trail exists. (iii Give an example of a spanning tree in the graph (iv) Two identical looking bags are on a table....