Statistics

Problem Statement for "AverageAverage"

Problem Statement

Given a int[] numList, for each non-empty subset of numList, compute the average of its elements, then return the average of those averages.

Definition

Class:
AverageAverage
Method:
average
Parameters:
int[]
Returns:
double
Method signature:
double average(int[] numList)
(be sure your method is public)

Notes

  • The returned value must have an absolute or relative error less than 1e-9.

Constraints

  • numList will contain between 1 and 8 elements, inclusive.
  • All elements of numList will be between -1000 and 1000, inclusive.
  • All elements of numList will be distinct.

Examples

  1. {1,2,3}

    Returns: 2.0

    The non-empty subsets of numList are: {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, and {1,2,3}, whose respective averages are: 1, 2, 3, 1.5, 2, 2.5, and 2. The average of the averages is 2.

  2. {42}

    Returns: 42.0

    There is only one non-empty subset to consider.

  3. {3,1,4,15,9}

    Returns: 6.4

  4. {977}

    Returns: 977.0

  5. {178}

    Returns: 178.0

  6. {-315}

    Returns: -315.0

  7. {437,-372}

    Returns: 32.5

  8. {-262,-676}

    Returns: -469.0

  9. {-114,-401}

    Returns: -257.5

  10. {90,-200,-223}

    Returns: -111.0

  11. {-213,-955,153}

    Returns: -338.3333333333333

  12. {104,763,569}

    Returns: 478.6666666666667

  13. {-735,-967,704,473}

    Returns: -131.25

  14. {-432,-126,-773,-684}

    Returns: -503.75

  15. {-757,642,21,761}

    Returns: 166.75

  16. {-22,157,-580,-984,658}

    Returns: -154.2

  17. {766,-358,-215,-156,-343}

    Returns: -61.2

  18. {-727,725,755,23,974}

    Returns: 350.0

  19. {463,211,-276,-117,-425,341}

    Returns: 32.833333333333336

  20. {-790,-79,153,572,-826,-717}

    Returns: -281.1666666666667

  21. {-728,-933,-654,973,-622,-824}

    Returns: -464.6666666666667

  22. {533,214,553,-812,555,-448,265}

    Returns: 122.85714285714286

  23. {-994,-214,-587,828,571,-596,-622}

    Returns: -230.57142857142858

  24. {961,-862,-36,191,-38,136,855}

    Returns: 172.42857142857142

  25. {-353,-586,907,237,-688,-736,302,-537}

    Returns: -181.75

  26. {114,710,-205,-659,-871,900,-112,611}

    Returns: 61.0

  27. {-392,-348,230,742,-345,380,-631,773}

    Returns: 51.125

  28. {0}

    Returns: 0.0

  29. {-1000,-999,-998,-997,997,998,999,1000}

    Returns: 0.0

  30. {3, 1, 4, 15, 9 }

    Returns: 6.4

  31. {0 }

    Returns: 0.0

  32. {1000, 12, 124, 54, 457, 45, 454 }

    Returns: 306.57142857142856

  33. {1, 2, 3 }

    Returns: 2.0

  34. {1, 15, 9, 3, 4, 1000, -1000, -999 }

    Returns: -120.875

  35. {2, 3, 9 }

    Returns: 4.666666666666667

  36. {-1, 1, 2, 3, 4, -5, -1000, 0 }

    Returns: -124.5

  37. {42, 14, 15, 99, 0 }

    Returns: 34.0

  38. {0, 2, -1 }

    Returns: 0.3333333333333333

  39. {91, -100, 4, 10, -45, 67, -89, -22 }

    Returns: -10.5

  40. {1, 2, 3, 4, 9, 13, 15 }

    Returns: 6.714285714285714

  41. {467, 456, 234, 879, 657, 567, 89, -324 }

    Returns: 378.125


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: