Accelerated C++: Clarification on the wording of exercises

Discussion in 'C++' started by Frankie Montenegro, Oct 14, 2005.

  1. 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.
     
    Frankie Montenegro, Oct 14, 2005
    #1
    1. Advertising

  2. 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
     
    Karl Heinz Buchegger, Oct 14, 2005
    #2
    1. Advertising

  3. "Karl Heinz Buchegger" <> wrote in message
    news:...

    >> 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.
     
    Andrew Koenig, Oct 14, 2005
    #3
  4. Thanks guys.
    It makes more sense now. Mr. Koenig, it is good to now you can be found
    around here.
    Regards,
    F.
     
    Frankie Montenegro, Oct 14, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lambda
    Replies:
    4
    Views:
    536
    Lambda
    Apr 24, 2008
  2. Paulo Jorge de O. C. de Matos

    Question on Wording

    Paulo Jorge de O. C. de Matos, Apr 26, 2008, in forum: C Programming
    Replies:
    8
    Views:
    341
    David Thompson
    May 5, 2008
  3. Jason R. Coombs
    Replies:
    0
    Views:
    228
    Jason R. Coombs
    Jun 13, 2008
  4. swivelhead
    Replies:
    12
    Views:
    1,483
    swivelhead
    Jul 2, 2008
  5. grocery_stocker
    Replies:
    4
    Views:
    257
    grocery_stocker
    May 2, 2009
Loading...

Share This Page