Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Accelerated C++: Clarification on the wording of exercises

Reply
Thread Tools

Accelerated C++: Clarification on the wording of exercises

 
 
Frankie Montenegro
Guest
Posts: n/a
 
      10-14-2005
Hi everyone,
I must say that, even though I think
that Accelerated C++ by Koenig and Moo is an awesome
text, the wording of exercises is very poor. I
spend half the time just trying to figure out what is
it they want me to do. Anyway, I somehow managed
untill chapter 5 but now I am hopelessly stuck.
But I am completely lost with the wording of the
following three exercises:
5-2.
Write the complete new version of the student-grading
program, which extracts records for failing students,
using vectors. Write another that uses lists. Measure
the performance difference on input files of ten
lines, 1000 lines, and10000 lines.
My question: What does "complete new version" mean?
What improvements should I make? Maybe use iterators
instead of indices?

5-3.
By using a typedef, we can write one version of the
program that implements either a vector-based solution
or a list-based one. Write and test this version of
the program.
My question: I will assume that this problem refers to
the 5-2 although this is not quite clear. I am sure I
am missing something, but I can't figure out what
else is there to this problem except stating
"typedef vector container;" or "typedef list
container;"
and then using a type "container" in the rest of the code??

5-4.
Look again at the driver functions you wrote in the
previous exercise. Note that it is possible to write a
driver that differs only in the declaration of the
type for the data structure that holds the input file.
If your vector and list test drivers differ in any
other way, rewrite them so that they differ only in
this declaration.
My question:
OK, isn't this what I just did in 5-3?

Thanks everyone for help and apologies for a long-ass
question.

 
Reply With Quote
 
 
 
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      10-14-2005
Frankie Montenegro wrote:

> I
> spend half the time just trying to figure out what is
> it they want me to do.


You are lucky.
I have this in real life with customers everyday

>
> But I am completely lost with the wording of the
> following three exercises:
> 5-2.
> Write the complete new version of the student-grading
> program, which extracts records for failing students,
> using vectors. Write another that uses lists. Measure
> the performance difference on input files of ten
> lines, 1000 lines, and10000 lines.
> My question: What does "complete new version" mean?
> What improvements should I make? Maybe use iterators
> instead of indices?


I don't know what happend in the previous assignments,
I never read that book. But I guess the author
means: Throw away what you have so far and rewrite a new
version. If chapter 5 covered iterators, then I guess
yes: The author wants you to write a version which uses
iterators, especially in the light of the next assignment.

>
> 5-3.
> By using a typedef, we can write one version of the
> program that implements either a vector-based solution
> or a list-based one. Write and test this version of
> the program.
> My question: I will assume that this problem refers to
> the 5-2 although this is not quite clear. I am sure I
> am missing something, but I can't figure out what
> else is there to this problem except stating
> "typedef vector container;" or "typedef list
> container;"
> and then using a type "container" in the rest of the code??


That's what the assignment asks for.

>
> 5-4.
> Look again at the driver functions you wrote in the
> previous exercise. Note that it is possible to write a
> driver that differs only in the declaration of the
> type for the data structure that holds the input file.
> If your vector and list test drivers differ in any
> other way, rewrite them so that they differ only in
> this declaration.
> My question:
> OK, isn't this what I just did in 5-3?


There is more then 1 way to skin a cat.
The author wants you to skin the cat exactly his way.
If your result of 5-3 fits 5-4 then there is
nothing you have to do.

--
Karl Heinz Buchegger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Andrew Koenig
Guest
Posts: n/a
 
      10-14-2005
"Karl Heinz Buchegger" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>> But I am completely lost with the wording of the
>> following three exercises:
>> 5-2.
>> Write the complete new version of the student-grading
>> program, which extracts records for failing students,
>> using vectors. Write another that uses lists. Measure
>> the performance difference on input files of ten
>> lines, 1000 lines, and10000 lines.
>> My question: What does "complete new version" mean?
>> What improvements should I make? Maybe use iterators
>> instead of indices?


> I don't know what happend in the previous assignments,
> I never read that book. But I guess the author
> means: Throw away what you have so far and rewrite a new
> version. If chapter 5 covered iterators, then I guess
> yes: The author wants you to write a version which uses
> iterators, especially in the light of the next assignment.


It means to start with what's shown in the book and make it complete--that
is, add to it the code that you need in order to be able to compile and run
it. The point of this exercise is for you to measure the performance
difference between vectors and lists.

>> 5-3.
>> By using a typedef, we can write one version of the
>> program that implements either a vector-based solution
>> or a list-based one. Write and test this version of
>> the program.
>> My question: I will assume that this problem refers to
>> the 5-2 although this is not quite clear. I am sure I
>> am missing something, but I can't figure out what
>> else is there to this problem except stating
>> "typedef vector container;" or "typedef list
>> container;"
>> and then using a type "container" in the rest of the code??

>
> That's what the assignment asks for.


Whether you need to do anything else depends on how careful you were in your
use of vectors. When you change a vector to the corresponding list, you may
find that parts of your program don't work any more if they depend on
operations that vector provides but list doesn't.

>> 5-4.
>> Look again at the driver functions you wrote in the
>> previous exercise. Note that it is possible to write a
>> driver that differs only in the declaration of the
>> type for the data structure that holds the input file.
>> If your vector and list test drivers differ in any
>> other way, rewrite them so that they differ only in
>> this declaration.
>> My question:
>> OK, isn't this what I just did in 5-3?

>
> There is more then 1 way to skin a cat.
> The author wants you to skin the cat exactly his way.
> If your result of 5-3 fits 5-4 then there is
> nothing you have to do.


The point of this is exercise is to prepare the ground for templates.


 
Reply With Quote
 
Frankie Montenegro
Guest
Posts: n/a
 
      10-14-2005
Thanks guys.
It makes more sense now. Mr. Koenig, it is good to now you can be found
around here.
Regards,
F.
 
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
Is it okay to ask questions about Accelerated C++ exercises here? swivelhead C++ 12 07-02-2008 10:56 AM
Wording suggestion for documentation (Data Model) Jason R. Coombs Python 0 06-13-2008 12:16 AM
Question on Wording Paulo Jorge de O. C. de Matos C Programming 8 05-05-2008 04:10 AM
Questions with Accelerated C++ exercises of chapter 7 Lambda C++ 4 04-24-2008 01:52 AM
Question on wording Kayla Digital Photography 11 07-19-2005 12:48 AM



Advertisments