Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Accelerated C++ exercise

Reply
Thread Tools

Accelerated C++ exercise

 
 
utab
Guest
Posts: n/a
 
      02-13-2006
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.

 
Reply With Quote
 
 
 
 
Mark P
Guest
Posts: n/a
 
      02-13-2006
utab wrote:
> 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?
 
Reply With Quote
 
 
 
 
Diego Martins
Guest
Posts: n/a
 
      02-14-2006
no homeworks, please

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accelerated C++: Exercise 3-2 Xernoth C++ 10 04-15-2007 09:03 PM
Accelerated C++ - exercise 0-1 arnuld C++ 10 03-18-2007 06:54 PM
Accelerated C++ exercise 8.8 utab C++ 8 04-16-2006 06:18 PM
an interesting exercise by Accelerated C++ utab C++ 3 02-16-2006 03:50 PM
Accelerated C++: exercise 6-1 Pete C++ 14 01-03-2006 08:34 PM



Advertisments