Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Kindella Angel has 101 n dalmation pups that she loves very much and would never make coats out of them. However, while most of
Kindella Angel has 101 n dalmation pups that she loves very much and would never make coats out of them. However, while most of these puppies are oh so very good pups, Kindella admits that some of them are better than others, and better pups deserve more treats. Help Kindella sort her puppies, so she can decide who gets the most treats. (a) [6 points] Kindella has decided that the best pups have the most spots. She knows that the total number of spots on all of the puppies is exactly n101. Given a list of the spots on each pup, describe an efficient algorithm to sort these pupperinos by their number of spots. (b) [6 points] Although spots are very important, Kindella has found that many puppies have the same number of spots. She concludes that the best pups actually have the highest spot density: each pupper has an integer representing the surface area of its body, and a pup's spot density is its number of spots divided by its surface area. Given a list containing each pup's spot number and surface area, describe an efficient algorithm for Kindella to sort her puppies by spot density, once and fur all.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
a To sort the puppies based on the number of spots efficiently we can use a sorting algorithm called Counting Sort Heres how the algorithm works 1 Cre...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started