CS 70

Homework 4

In this assignment, you will practice

  • Writing code with dynamically allocated arrays of both primitives and objects on the heap.
  • Memory management using new and delete.
  • Debugging memory management problems with valgrind.
  • Writing code from scratch.
  • Code design by writing function “stubs”.
  • Writing a Makefile.
  • Testing your code (using the CS 70 testing library).
  • Experimentally investigating the resource usage of your code.

Quinn's Train

Quinn is a train engineer whose company transports packages. The train visits stations and picks up or delivers packages as it travels.

  • If Quinn's train gets completely full of packages, all of the packages need to be moved to a larger train in order to make room for more packages.
  • If there is enough unused space in the train, Quinn might decide to move all of those packages to a smaller train.

In this scenario, Quinn must deal with the following financial concerns:

  1. Customers pay Quinn a shipping fee when they drop off a package.
  2. Adding a package to the train has a handling cost, which Quinn pays for with labor.
  3. Moving packages to a new train also has a handling cost, which Quinn also pays for.

Quinn would like you to help design a simulation that takes these concerns into consideration so that the train company can assess the financial trade-offs of different train resizing protocols.

  • LHS Cow speaking

    (Pssst! Quinn's business problems are actually metaphors for the computational/resource costs of data structure operations, which we will be focusing on very soon!)

  • Dog speaking

    Ooh! Watcha whispering about?!

  • LHS Cow speaking

    Don't worry about it. Ready to help Quinn?

  • Dog speaking

    Let's do it!!!

Let's Go!

Both team members should accept the assignment:

Outline

Useful Information

Other Resources

You might find Sections 12.1 and 12.2 of the textbook, C++ Primer, 5th Edition, to be helpful.

As always, ask and answer questions on Piazza!

In addition, please review the following pages in the Help Pages:

Grading

Completing this assignment is worth 100 points, and will be graded as follows:

  • 6 points: Team Contract
  • 18 points: Written Questions
  • 5 points: Makefile
  • 10 points: Repository Quality (code compiles without warnings, cpplint, no extra/missing files)
  • 27 Points: Code Correctness
  • 20 Points: Coding Style (clarity, elegance, style)
  • 9 Points: Tests of Train Growth Strategies
  • 5 Points: Correctly denoting all team members in Gradescope submission

(When logged in, completion status appears here.)