Accelerated C++ exercise

U

utab

Suppose we wish to find the median of a collection of values. Assume
that we have read some of the values so far, and that we have no idea
how many values remain to be read. Prove that we cannot afford to
discard any of the values that we have read. Hint: One proof strategy
is to assume that we can discard a value, and then find values for the
unread—and therefore unknown—part of our collection that would cause
the median to be the value that we discarded.

As a try;

Lets say we have read so far

5 10 34 72

and we want to read 6 more values as an example

43 32 45 56 78 89

Actually I did not understand what is meant above? Could you please
give an explanation for this problem.

Thx.
 
M

Mark P

utab said:
Suppose we wish to find the median of a collection of values. Assume
that we have read some of the values so far, and that we have no idea
how many values remain to be read. Prove that we cannot afford to
discard any of the values that we have read. Hint: One proof strategy
is to assume that we can discard a value, and then find values for the
unread—and therefore unknown—part of our collection that would cause
the median to be the value that we discarded.

As a try;

Lets say we have read so far

5 10 34 72

and we want to read 6 more values as an example

43 32 45 56 78 89

Actually I did not understand what is meant above? Could you please
give an explanation for this problem.

Thx.

The point is that after you've read n values, if you don't know how many
more are coming, *any* of those n values could be the median depending
upon what's read next. Here's a simple example:

Say you've read {10 20 30}

Suppose the remaining numbers are: {40 50} OR {15 25} OR {0 5}. In each
of these cases, what's the resulting median value?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top