CPS 100: Groupwork # 2: Sequences and Lists

Overview

You should start this group activity by introducing each member of the group. One group member should be the scribe, this person is responsible for recording the group's endeavors.

You will design and implement several C++ functions as part of this work. Don't worry about getting the syntax exactly right, but think about it a little.

Sequences

Write the function "RemoveDupes" whose header is given below. You'll need to use "DigitSeqIterator" objects. You may find it useful to write auxiliary functions called from "RemoveDupes".

void RemoveDupes(const DigitSeq & seq, DigitSeq & noDupes)
// noDupes is seq without duplicates, more precisely:
// precondition: seq = d1, d2, d3, ..., dn
// postcondition: all elements of noDupes are in seq, no element of
//                noDupes is repeated, and elements in noDupes
//                appear in the same order relative to each other as they
//                do in seq
// example: seq = (1, 2, 1, 4, 2, 1, 3, 2)
//      noDupes = (1, 2, 4, 3)

Lists

Linked lists of strings are implemented using the struct "WordNode" declared below. Write the function "RemoveDupes" that creates a new linked list of words containing the non-duplicates from "words" and returns a pointer to the first node of this newly created list. Lists are implemented WITHOUT header nodes.

struct WordNode
{
    string info;
    WordNode * next;
};

WordNode * RemoveDupes(WordNode * words)
// postcondition: returns pointer to first node of a linked-list
//                containing same strings as in words, but no duplicates
//                strings in returned list are in same order as in words