Question

For each of the following recursive methods available on the class handout, derive a worst-case recurrence...

For each of the following recursive methods available on the class handout, derive a worst-case recurrence relation along with initial condition(s) and solve the relation to analyze the time complexity of the method. The time complexity must be given in a big-O notation.

1. digitSum(int n) - summing the digits of integer:

int digitSum(int n) {

                if (n < 10)

                                return n;

                return (digitSum(n/10) + n%10);

}

2. void reverseA(int l, int r) - reversing array:

void reverseA(int l, int r) {

                if (l < r) {

                                int t = A[l];

                                A[l] = A[r];

                                A[r] = t;

                                reverseA(l+1, r-1);

                }

}

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
For each of the following recursive methods available on the class handout, derive a worst-case recurrence...
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
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
ADVERTISEMENT