1 |
h03 |
CS24 S17 |
Name: | ||||
---|---|---|---|---|
(as it would appear on official course roster) | ||||
Umail address: | @umail.ucsb.edu | section |
||
Optional: name you wish to be called if different from name above. | ||||
Optional: name of "homework buddy" (leaving this blank signifies "I worked alone" |
h03: Chapter 3, section 3.1 -3.3
ready? | assigned | due | points |
---|---|---|---|
true | Wed 04/19 02:00PM | Wed 04/26 05:00PM |
You may collaborate on this homework with AT MOST one person, an optional "homework buddy".
MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the three lowest scores (if you have zeros, those are the three lowest scores.)
Please:
- No Staples.
- No Paperclips.
- No folded down corners.
Complete your reading of Chapter 3, section 3.1- 3.3 (If you don’t have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”).
-
1. (3 pts) What are three key operations that can be performed on the bag class? Explain what each operation achieves.
2. (2 pts) What is the fundamental difference between the bag container class and the ADTs covered in Chapter2 ?
3. (2 pts) Which statement in the definition of the bag class, when modified, allows a user to create a bag containing elements of any datatype?
4. (2 pts) What is the rationale behind defining the bag's CAPACITY as a const static public member variable. Justify all those attributes.
5. (8 pts) What is the bug in the code provided in Figure 3.7 (implementation of the += operator). Provide the correct code below.
6. (3 pts) Complete as many of the self-test exercises for section 3.1 and 3.2 as you can. Check your answers with those provided in the book. Then, write your favorite exercise (and the solution) below: