CS 301 - Data Structures and Algorithms I - Fall 2002
Project 4


Loyola College > Department of Data Structures and Algorithms > CS 301 > Projects > Project 4

Due

Monday, December 9 at 11:59pm

Purpose

This project involves the use and modification of several of the data structures presented during the semeseter.

Introduction

One tool the NCAA uses to determine what teams make the basketball championship tournament is a measure called the Ratings Percentage Index (RPI). A team's RPI is the weighted average of its winning percentage (25%), it opponents' winning percentage (50%) and it opponents' opponents' winning percentage (25%).

For this project we will consider a simpler formula that involves only a team's winning percentage (33 1/3%) and the average of its opponents' winning percentages (66 2/3%). For example, suppose there are 5 teams that have played games with outcomes given by the following table (the home team's scoreis listed first).

Away Team
Arizona Boston College Centenary Davidson East Carolina
Home Team Arizona 71-60 80-50 60-52
Boston College 75-65
Centenary 63-89 64-57
Davidson 64-82 76-64
East Carolina 40-72 81-90

The standings would be

Team Wins Losses Pct
Arizona 4 0 1.000
Boston College 3 1 0.750
Centenary 2 2 0.500
Davidson 1 3 0.333
East Carolina 0 4 0.000

But the RPI tells a different story:

Team RPI Wins Losses
Boston College 0.625 3 1
Arizona 0.500 4 0
Centenary 0.458 2 2
Davidson 0.458 1 3
East Carolina 0.458 0 4

Boston College gets a higher rating than Arizona because Boston College's opponents have a higher winning percentage than Arizona'a: B.C. played Arizona (1.000), Centenary twice (0.500), and Davidson (0.250). Arizona played B.C. (0.750), Davidson (0.250), and East Carolina twice (0.000). The respective RPIs are then 2 / 3 * (1.0 + 2 * 0.5 + 0.25) / 4 + 1 / 3 * 0.75 = 0.625 and 2 / 3 * (0.75 + 0.25 + 2 * 0.0) / 4 + 1 / 3 * 1.0 = 0.500. (Note that if a team played an opponent twice, that opponent's winning percentage counts twice in the average).

Assignment

This is a team project. Work in pairs.

Your program should read from standard input a list of game results with one game per line. Each line of input will contain a date in month/day/year format, the name of the away team, its score, the name of the home team, and finally the home team's score. For example, for the games used in the last section's example, the input would be

1/1/2002 Arizona 71 Boston College 60
1/2/2002 Arizona 80 Davidson 50
1/3/2002 Arizona 60 East Carolina 52
1/4/2002 Boston College 75 Centenary 65
1/5/2002 Centenary 63 Boston College 89
1/6/2002 Centenary 64 Davidson 57
1/7/2002 Davidson 64 Boston College 82
1/8/2002 Davidson 76 East Carolina 64
1/9/2002 East Carolina 40 Arizona 72
1/10/2002 East Carolina 81 Centenary 90

Your program should then write to standard output a list of teams sorted by RPI. Each team should be listed with its rank, RPI, and record. For example, for the given input the output should be

  1 0.6250 Boston College (3-1)
  2 0.5000 Arizona (4-0)
  3 0.4583 Centenary (2-2)
  3 0.4583 East Carolina (0-4)
  3 0.4583 Davidson (1-3)

Files

Suggestions

This project is all about choosing and modifying the data structures presented during the semester. My implementation, for example, uses 7 classes (plus some code in main) but 6 of those are fairly simple modifications of different versions of the List class. The other is essentially an object that holds two Lists.

For each team you will have to keep track of its name, its record, and its opponents.

You may find it helpful to have a data structure that keeps track of team names you've seen so far. Each time you read a team name, you would check the structure to see if it's a new team. If it isn't new, you should update its record and opponents. It it is new, you should create a new structure to hold that information.

Sorting the final list of teams can be done with a sorted list: throw all the (team, RPI) pairs into a list sorted by RPI and then iterate through the list.

If you want a structure that works like Java's Vector class, it is fairly easy to modify the implementation of an unsorted list as a dynamically allocated array to include a getElementAt(int index) method.

Be careful when reading team names. The >> operator will stop at the first blank character when reading into a string. You want to read until you get to a digit. istream has a function called peek that will return the next character to be read without actually reading it. There is a function in cctype called isdigit that can be used to test if that character is a digit.

Additional Requirements

Grading:

Submissions

Submit your lab by creating a tar file containing your makefileand all the code necessary to compile your project. I should be able to run your project by untarring, typing make and then ./proj4.x < scores. Attach your tar file to an e-mail message sent to jglenn@cs.loyola.edu. The body of your message should must contain a pledge that you have not violated the Honor Code in the completion of the project.