#### Details of this Paper

##### computer science

**Description**

solution

**Question**

2. a. Write a pseudocode for a divide-and-conquer algorithm for finding values;of both the largest and smallest elements in an array of n numbers.;b. Set up and solve (for n = 2k) a recurrence relation for the number;of key comparisons made by your algorithm.;c. How does this algorithm compare with the brute-force algorithm for;this problem?;3. a. Write a pseudocode for a divide-and-conquer algorithm for the exponentiation;problem of computing an where a > 0 and n is a positive;integer.;b. Set up and solve a recurrence relation for the number of multiplications;made by this algorithm.;c. How does this algorithm compare with the brute-force algorithm for;this problem?;A nswer Submitted by Abhishek Jain on Wed, 2013-01-30 11:52 teacher rated 140 times 4.67143 price: $5.00;Answer in detail;body preview (0 words);file1.docx preview (435 words);xxxxxx 2. xx Call Algorithm xxxxxx xxxxxxx? xxx minval, xxxxxxx xxxxx;xxxxxxxxx xxxxxx xxxxxxxxx xxxxxxx maxval);xxxxxxx the values xx the xxxxxxxx and xxxxxxx xxxxxxxx xx a given subarray;xxxxxxxx A portion of array xxxxxx? xx xxxxxxx indices l and r (l? xx;//Output: xxx xxxxxx of the smallest and xxxxxxx xxxxxxxx xx xxxxxxx;xxxxxxxxxx xx minval xxx maxval, xxxxxxxxxxxx;if r x x;minval? A[l], xxxxxx? A[l];xxxx if r? x = 1;xx xxxx? A[r];minval? xxxxx xxxxxx? xxxx;xxxx minval? xxxxx maxval? xxxx;else xxx? x > x;MinMax(A[l.._(l x xxxxxxx minval, xxxxxx);xxxxxxxxxxxx + r)/2_ + 1..r], xxxxxxxx maxval2 x;if minval2 maxval;maxval? maxval2;x x Assuming for xxxxxxxxxx xxxx x = xxx xx obtain xxx xxxxxxxxx xxxxxxxxxx for the number xx element xxxxxxxxxxx C(n);C(n) = 2C(n/2) + x xxx n > xx C(2) x xx C(1) x xx;xxxxxxx xx xx backward substitutions xxx n x xxx k? xx xxxxxx xxx following;xxxxxx xx xxxxxxx?1)) x x;x 2[2C(2^(k?xxx x 2] x x x;- - -;more text follows;- - -;Buy this answer;Try it before you buy it;Check plagiarism for $2.00

Paper#73137 | Written in 18-Jul-2015

Price :*$22*