113k views
1 vote
Consider the problem where you are given an array of n digits [d and a positive integer b, and you need to compute the value of the number in that base In general, you need to compute For example: (1011 )2 = 1(11+ 1(21+0(4) + 1(8) (1021 )3 =-1(1) + 2(3) 0(9) + 1 (27) (1023)4 3(1) +2(4) 0(16)1(64) 34, and In these examples, I give the digits in the order dad2dido, which corresponds to how we would normally write these numbers, though you can assume that d, is in indexi of the array for the questions below. (Yes, the indices will be numbered 0 to n - , n1 to n.) 1. Give pseudocode for a divide-and-conquer algorithm that solves this prob- lem by dividing the digit array into two subarrays of (roughly) the same size. For example, dsd4d3d2dido would be split into dsd4ds and d2dido 2. Give pseudocode for a divide-and-conquer algorithm that solves this prob- lem by dividing the digit array into two interleaved arrays of (roughly) the same size For example, dsdjd3d2dido would be split into d,dadi and dd2do

User Yuan Chen
by
5.0k points

1 Answer

5 votes

Answer:

The question is completely described and solved below:

Consider the problem where you are given an array of n digits [d and a positive integer-example-1
User JiniKJohny
by
5.0k points