CIS 181 Intro to Comp Sci
Class 21, April 26, 2005


ASSIGNMENT:

Read D&D, Chapter 17 (pp. 942-978)

Exercise Due Tuesday, May 3

In class we discussed the ConcordNode and ConcordList classes. I provided definitions and implementations of these classes, along with a driver program to see how the classes worked (including a print function associated with ConcordList that simply printed out the word field of each list element).

For Tuesday, provide the print member function (of ConcordList) for the assignment that prints the word/frequency pairs for each element in the list in tabular form (this is the one that will produce the alphabetical listing for the project). You may assume that the list is stored alphabetically. Alter the driver program provided so that it reads in both a word and a frequency when inserting into the list. Provide an option in the instructions that will allow the user to print out the word/frequency pairs in tabular format. Call the driver program and insert a number of words with their frequencies, and then choose the option that will call your new printing function to show that it works.

Exercise Tuesday, May 3

Provide the frequency-sorted print function that prints out the list elements "sorted" so that those words with the highest frequency are presented first. Please see the bottom of page 2 of the assignment where it provides some hints on how to do this. In particular, please note that it does not require sorting the list -- you just need to walk through the list several times in order to print out the elements.

Alter the driver program so that printing out the list ordered by frequency is an option in the instructions. Show that your function works by inserting a number of words with frequencies in a list, and then printing out the list sorted both alphabetically (or ordered the way the entries are in the list) and using your new member function to print them sorted by frequencies.


TODAY'S TOPICS
 
  1. Hand back and go over Test 2
  2. Hand out and discuss Project 4 due Tuesday, May 17

  3. Linked Lists --
    self-referential classes
    friends
    dynamic memory allocation
    constructors and destructors

    printing a linked list

    See the files
    http://www.cis.udel.edu/~mccoy/courses/cisc181-05s/programming-projects/clistnd.h
    http://www.cis.udel.edu/~mccoy/courses/cisc181-05s/programming-projects/clistnd.cc
    http://www.cis.udel.edu/~mccoy/courses/cisc181-05s/programming-projects/clist.h
    http://www.cis.udel.edu/~mccoy/courses/cisc181-05s/programming-projects/clist.cc
    http://www.cis.udel.edu/~mccoy/courses/cisc181-05s/programming-projects/clist-driver.cc