

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Data Structures and Algorithms; Subject: Computer Science and Engineering ; University: University of Nebraska - Lincoln; Term: Fall 2004;
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Section 1.1 #4, # Section 1.2 # Section 1.3 # Section 1.4 # Section 2.2 #1, # Section 2.3 #
Given below is a generic List ADT. From this ADT, write three implementations in C++, one using a stack, one using a priority queue, and one using a linked list.
bool isEmpty(FloatList list) – returns true if the list is empty, otherwise false.
FloatList constructList(float newElement, FloatList oldList) – constructs a new list with copies of all of the elements from oldList and newElement Precondition: oldList is a list with 0 or more elements Postcondition: the list returned by constructList contains newElement
float firstElement(floatList list) – returns the first element in the list, but does not remove it Precondition: isEmpty(list) == false Postcondition: none
FloatList restOfList(FloatList oldList) – returns a copy of list that contains every element except firstElement(oldList) Precondition: oldList is a list with 1 or more elements Postcondition: newList = restOfList(oldList) newList contains every element in oldList except the first element
Note : This is an abstract definition of the operations that the List ADT should perform. It is your job to create classes for this ADT which implement at least these features.
What the program does
We are interested in generating forecasts of sales data based on the three calculations below. Your task is to write a program called forecast that will take as its arguments the name of a data file and the name of a product. From these arguments, the program will extract the data needed to perform calculations for the specified product. You must use the generic ADT List defined above. For the data file, use the comma- delimited file similar to the one for Homework 0.
The output of the program, if the product is listed in the data file, should be exactly as below (truncate values to integers for the output, but not during the calculations, as this would decrease the accuracy of the results):
Product: Wheel Simple average: 2491 Slope: 2019 Linear regression: 2148
If the product is not found in the file, the output should be exactly as below:
Product productName not found in fileName
Where productName is the name of the product and fileName is the name of the input file. For example, if the product Wheel is not found in the file Forecast, the output should be exactly as below:
Product Wheel not found in Forecast
Desired forecasts I. Simple average – use the average number of historical products needed in the file given to estimate the next period’s value.
II. Slope – use the slope of the line between the first and last points to estimate the future value
Intercept Firsthistoricalvalue Slope First periodnumber
First periodnumber Last periodnumber
Firsthistoricalvalue Lasthistoricalvalue Slope
III. Linear regression – use a linear regression to find a best-fitting line, and then evaluate the point on the line that represents the next period to find its forecasted value.
Numberof periods
SumY Slope SumX Intercept
Numberof periods SumXSquared SumX SumX
Numberof periods SumXY SumX SumY Slope
SumXSquared Period number Periodnumber
SumXY Periodnumber Historicalvalue
SumY Historicalvalues
SumX Periodnumber