Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have two friends who want to find the average number of hours they sleep per night, over the course of a month ( 3

You have two friends who want to find the average number of hours they sleep per night, over the course of a month (30 days).
Alice uses the following algorithm: Each morning, she records the number of hours she slept the prior night. At the end of 30 days, she adds up all of the numbers that she recorded, and then divides the result by 30.
Bob uses the following algorithm: he starts with a total of 0. Each morning, he adds the number of hours he slept the prior night to his current total, to get the new total. (In other words, he keeps a running total of the number of hours of sleep so far in the month). At the end of the 30 days, he divides the running total by 30.
Both of these algorithms will indeed give the average number of hours slept over the course of the month. Please explain why Alice might prefer her algorithm, and why Bob might prefer his. That is, what are the benefits and drawbacks of these two algorithms?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions