Question

Show WorkP4. (25 pts) [Ch5. Divide and Conquer] a. (10 pts) Briefly describe a divide and conquer algorithm for computing the sum of n

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution

P4

a)

Step 1

Partition(Divide) the list of "n" numbers into 2 different lists
Each list contains n/2 numbers

Step 2

Calculate the sum of each list of numbers recursively

Step 3

Add the results of two sums

---

b)

Answer


T(n)=2T(n/2)+1.
The meaning of 1 is that the addition of two sums

Master Method,

a=2
b=2
d=0
Therefore
a>bd this is third one
it gives O(n).

---

c)

Answer

we need to solve this recurrence using back substitution
T(n)
=2T(n/2)+ c
=2(2T(n/4)+c)+ c
=4T(n/4)+2c+c
=4(2T(n/8)+c)+2c+c
=8T(n/8)+4 c+2c+c
=n T(n/n) + c* sum_{i = 0}^ {(log n) – 1} 2i
=n+c 2log n
=n+cn
=n(1+c)

---

all the best

Add a comment
Know the answer?
Add Answer to:
Show Work P4. (25 pts) [Ch5. Divide and Conquer] a. (10 pts) Briefly describe a divide...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose that, in a divide-and-conquer algorithm, we always divide an instance of size n of a...

    Suppose that, in a divide-and-conquer algorithm, we always divide an instance of size n of a problem into 5 sub-instances of size n/3, and the dividing and combining steps take a time in Θ(n n). Write a recurrence equation for the running time T (n) , and solve the equation for T (n) 2. Suppose that, in a divide-and-conquer algorithm, we always divide an instance of size n of a problem into 5 sub-instances of size n/3, and the dividing...

  • Analysis Divide & Conquer: Analyze the complexity of algorithm A1 where the problem of size n...

    Analysis Divide & Conquer: Analyze the complexity of algorithm A1 where the problem of size n is solved by dividing into 4 subprograms of size n - 4 to be recursively solved and then combining the solutions of the subprograms takes O(n2) time. Determine the recurrence and whether it is “Subtract and Conquer” or “Divide and Conquer“ type of problem. Solve the problem to the big O notation. Use the master theorem to solve, state which theorem you are using...

  • (13 pts) Given an array AlI,2,. .. ,n] integers, design and analyze an efficient Divide-and-Conqu...

    (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:...

  • Question #4 (15 points) In class, we discussed a divide-and-conquer algorithm for matrix multiplication that involved...

    Question #4 (15 points) In class, we discussed a divide-and-conquer algorithm for matrix multiplication that involved solving eight subproblems, each half the size of the original, and performing a constant number of e(n) addition operations. Strassen's Algo- rithm, which we did not cover, reduces the number of (half-sized) subproblems to seven, with a constant number of e(n) addition and subtraction operations. Provide clear, concise answers to each of the following related questions. • (7 points). Express the runtime of Strassen's...

  • Please help me with this divide and conquer question. Please show your work. NOTES: The multiplication we covered in class are grade-school and Karatsuba multiplication algorithm. 3. Give the best al...

    Please help me with this divide and conquer question. Please show your work. NOTES: The multiplication we covered in class are grade-school and Karatsuba multiplication algorithm. 3. Give the best algorithm you can to convert an n digit number base 10 into binary. Here, we are counting operations on single digits as single steps, not arithmetic operations. You can use any of the multiplication algorithms we described in class.) 3. Give the best algorithm you can to convert an n...

  • Question 1. Solving Recursive Relations [3 mark]. A naive multiplication of two matrices of order n...

    Question 1. Solving Recursive Relations [3 mark]. A naive multiplication of two matrices of order n requires O(nᵒ) additions. By using a divide and conquer approach, Strassen devised another algorithm that requires T(n) additions where T(n) = 7T(n/2)+cna, where c is a constant independent of n and T(1) = 0 (as multiplying two numbers re- quires no additions). Use the method of backward substitution (introduced in Week 2's lecture) to show that Strassen’s algorithm requires O(nlog27) = O(n2.81) additions, which...

  • If someone can help with 3 3) To multiply 2 n bit binary numbers the straightforward way takes (r) time because each digit of each number multiplies each digit of the other number. (The aditions f...

    If someone can help with 3 3) To multiply 2 n bit binary numbers the straightforward way takes (r) time because each digit of each number multiplies each digit of the other number. (The aditions from carying are lower order terms.) Consider the following divide- and-conquer algorithm, which assumes, for simplicity, that n is a power of 2: Split each number into 2 collections of bits, the high order bits and the low order bits. For convenience, call the two...

  • URGENT Question 3 25 pts ArrayMystery: Input: n: a positive integer Pseudocode: Let output be an...

    URGENT Question 3 25 pts ArrayMystery: Input: n: a positive integer Pseudocode: Let output be an empty array For i = 1 to n j = 1 While ij <= n Addj to the end of output j - j + 1 Return output Answer the following questions about the ArrayMystery algorithm above. a) How many times will the inner while loop iterate? You should express your answer in terms of i and n, using Big-Oh notation. Briefly justify your...

  • Please show work. Thank you for your help. 7. (10 pts) First, give in pseudocode a...

    Please show work. Thank you for your help. 7. (10 pts) First, give in pseudocode a procedure DELETE(A, i) that deletes Ali] from max binary heap A that currently has n elements. Then analyze carefully the time complexity of your algorithm. Note: If it is easier to assume that the binary heap is stored in A[1..n) you may do this. Just indicate if you are assuming that the array is stored in A[1..n) or Afo..n-1). Hint: Use ideas from the...

  • - Approach and show your work in exactly the same way as demonstrated in the example...

    - Approach and show your work in exactly the same way as demonstrated in the example below -    Use the Master Theorem to characterize and solve the following recurrence equations by stating at the end which case was used and why: T(n) = 25T(n/5) + n T(n) = 36T(n/6) + (n log n)2 T(n) = 8T(n/3) + n2 Theorem        T(n) = c                          if n = 1        T(n) = a T(n/b) + f(n)     if n > 1...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT