SE 598, Data Structures and Algorithms

STL Set-Multiset Programming Assignment, due 5:00 p.m. Wednesday, 2 August


Introduction

This assignment adds no new features, but rather goes back and re-plows old ground.

Problem Statement

In the dequeue assignment you added the order command to readmbox to re-arrange the messages in the message list. Currently, the order command has two forms:
order label word
to order messages according to the appearance of word in header fields, and
order
to re-establish the original message order. In this assignment you'll add a third format for the order command.

The new order command format is

order word
The one-argument form of the order command searches the entire message header for occurrences of word, and then orders the messages according to the number of occurrences of word each message contains in its header. Messages are placed in descending order on the number of occurrences of word in each header; messages having the same number of occurrences maintain their relative order in the new message list.

For example, suppose the message list is

1:0 2:2 3:4 4:0 5:1 6:1
where i:j indicates that message i contains j occurrences of word. Then the order command
order word
would re-order the message list to
3:4 2:2 5:1 6:1 1:0 4:0
Note the old messages 5 and 6 both have one occurrence of word in their header and they maintain their relative order in the new message list.

This assignment does not change the behavior of the order command when it has zero or two arguments; this assignment just adds a new behavior when the order command has one argument.


This page last modified on 18 July 2000.