Suppose you want to calculate the average of 2^n different n-bit numbers. Give your (divide and conquer) algorithm, the running time, and the additional space requirements (how many intermediate values does your algorithm store, and how large are these values). Provide a proof.
Suppose you want to calculate the average of 2^n different n-bit numbers. Give your (divide and...
(13 pts) Given an array AlI,2,. .. ,n] integers, design and analyze an efficient Divide-and-Conquer algorithm to find some i and j, where j > 1, such that A[j]-Ali] is maximized. For example, given A 6, 1,3,8,4,5, 12,6], the maximum value of AL] - Ali] for j > i is 12-1 11 where j -7 and i 2. Give the underlying recurrence relation for your algorithm and analyze its running time. You should carefully state all details of your algorithm:...
2gcd(a/2, b/2) if a, b are both even ged(a, b/2)if a is odd, b is even ged(a,bged(a/2, b) if a is even, b is odd gcd(a -b)/2, b) if a, b are both odd (b) Give an efficient divide-and-conquer algorithm for greatest common divisor, based on the above. (c) Express the running time of your algorithm for the case where a and b are both n-bit numbers. Recall that dividing by two results in the removal of one bit from...
the question from the course COMP 4040 that Analysis of Algorithms if you want to answer it by code please use C or C++ 5. Algorithm Design (20 points) Input: array A contains n distinct numbers from 1 to n, in arbitrary order. Output: number of inversions (defined as the number of pair(i, j) of array indices with i < j and A[i] > Aj]) (a) (5 points) What array with elements from the set {1, 2, ..., n) has...
Suppose that P[1 · · · n] records the daily net profit GreatStore earns from days 1 to n. As with most stores, sometimes a P[i] is negative (i.e., when the store lost money that day) and sometimes it is positive (i.e., when the store made money that day). Alice, the owner of the store wants to use the information in P[1 · · · n]to plan for her vacation next year. Since she always has to worry about the...
Suppose you have an array S indexed from 1 to n which contains n numbers, not in any particular order, and you wish to count how many times a given number x occurs in S. Consider the recursive algorithm below for this which finds the number of occurrences of x in the index range i...j in S. Of course, solving the problem would involve an initial call to the algorithm for the range 1.n: int CountOccur (int i,j) { int...
1. How many different characters could be encoded using a six-bit code? 2. What is the numerical difference between ASCI a and ASClI 'AN if you treaj them as hexadecimal (hex) numbers? 3. The ASCII codes for the characters 'O' through '9' are what hex numbers? If an asynchronous frame is used to send ASCII characters in the form of bytes (8 bits), what is the shortest time it could take to send 1000 characters if each bit in a...
2. You are making a new account on your favorite social media website. This great new website offers the most fun way to steal all of your personal information! Long story short, you need a new password. ords can include upper-case letters, lower-case letters, numbers and the symbols you can r. Characters may be repeated. Please do not simplify your answers. get by holding Shift + a numbe (a) Suppose you want to make a 7, 8 or 9-character long...
Multivariable need help and some word explanation Iam a little bit confused on how to set up hy 2 dr xplain why the answers to parts (a) and (b) give the formula we want. e Distance Walked to an Airport Gate orts up in a terminal like points along a line. If you arriv , departure gates are often lined ate and proceed to another gate for a connecting flight, what propor inal will you have to walk, on average?...
Suppose your company needs to raise $45 million and you want to issue 30-year bonds for this purpose with a par value amount of $1000. Assume the required return on your bond issue will be 6%, and you're evaluating two issue alternatives: a 6% annual coupon bond and a zero-coupon bond. Your company's tax rate is 35% a-1. How many of the coupon bonds would you need to issue to raise the $45 million? Number of coupon bonds a-2. How...
Suppose your company needs to raise $41.6 million and you want to issue 20-year bonds for this purpose. Assume the required return on your bond issue will be 6.6 percent, and you're evaluating two issue alternatives: a 6.6 percent semiannual coupon bond and a zero coupon bond. Your company's tax rate is 21 percent. a. How many of the coupon bonds would you need to issue to raise the $41.6 million? How many of the zeroes would you need to...