Answers for 162 Midterm # 2 04/03/00                 Test Form A

 

1.        concatenated

2.        iterator

3.        A

4.        D (not on this test 2001)

5.        They are expandable. There is a library of functions available for working with vectors. You don’t have to keep passing around the size, the vector knows its own size.

6.        First, the only new memory to be allocated is for the new record. No other records have to be moved. Second, there is a pointer directly pointing to the end of the list, so the end can be found directly (not on this test 2001)

7.        Valid

8.        Invalid – only elements 0 – 5 exist – no element 7

9.        Invalid – size function works on whole vector, not on one element.

10.     Invalid à notation is used with iterators, not with whole list (not on this test 2001)

11.     found  y  at 4

12.     rest####| 8  (not covered 2001)

13.     Acct 1111  has balance 225.00

Acct 2222 has balance  200.00

Acct 3333 has balance  175.00

Acct 4444 has balance 150.00

Acct 5555 has balance 125.00

               

14.     list<Card>::iterator  ImHereItr;  (not on this test 2001 – but could have to do for vector iterators)

15.     vector<Song> mySongs(10);

16.     double MeanRoom (list<Room> rooms) {

int sum = 0;

list<Room>::iterator roomItr;

for (roomItr = rooms.begin( ); roomItr != rooms.end( ); roomItr++ ) {

                sum += roomItràGetSpace( );

}

double mean = sum / rooms.size( );

return mean;

        }

                In Main:

                Double mean = MeanRoom(roomList);

(not on this test 2001)