Question

Here is a recursive algorithm that answers the same question as posed on Group HW3, finding the number of people who are tall

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

Pls give thumbs up

a) The best case will be the people are standing in the ascending order of their heights i.e. the first person a1 is the smallest, a2 is the second smallest and so on

a1 < a2 < a3 < ... < an

In this case, the line will not even trigger a single time

(b)

The worst case will be the people are standing in the descending order of their heights i.e. the first person a1 is the tallest, a2 is second tallest and so on

a1 > a2 > a3 > ... > an

In this case, the line will trigger every time

(c) The run time of this will be Theta(n), since there is a single loop getting excercised from 1 to n

(d) The algorithm is correct since we are counting the comparison of the people with the last standing person and incrementing the count, if we see a match of this comparison

Add a comment
Know the answer?
Add Answer to:
Here is a recursive algorithm that answers the same question as posed on Group HW3, finding...
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