Exercises

1. Why is it not necessary to place the include "collection.h" before the primes function in primestest.c?

2. Why is primestest.c independent of the implementation of collection?

3. Why must primestest.c and collection.c be recompiled when changes are made in collection.h?

4. Change preferences.h and preferences.c so that the preferences and priorities arrays are implemented using a pointer array pointing to their rows, which are stored as row records in dynamic memory (see Section 2.3.3).

5. Run stablemarriages.c with your solution to Exercise 4.

6. What must be changed in list.h and list.c if you want to add another field (say, dividends) to the list records?

7. Change the files of Section 5.4 so that the name field of the stockrecords, instead of being an array, is a list. Treat that list as a data abstraction.

8. Write and compile a module for the queue data abstraction using the circular array implementation of Section 4.6.1.

9. Write and compile a module for the queue data abstraction using the list implementation of Section 4.6.3.

10. Create a program file ordlistexample.c. The program is to do what listexample.c does, except the list that is created is to have the records appear in alphabetical order by name. The list is to be treated as a data abstraction using list.h and list.c.

11. Compile, link, and run your program created in Exercise l0.

12. Define file list_record.h and list_record.c, and modify list.h and list.c to reflect these changes. The result should make list.h and list.c independent of details of the listrecords (as was done with the stack in Section 5.5). To accomplish this, you will have to remove and modify some operations from list.c, placing their modified versions in list_record.c, and some declarations from list.h, placing their modified versions in list_record.h.

13. Create a module for a data abstraction list of stacks.