Comp 121 Introduction to Data Structures.
Fall 2000Programming Assignment 0 -- Due Tuesday, September 5
Objective: To familiarize you with the programming environment you will be using for the remainder of this course.
Given an array A[0,...n-1], the insertion-sort sorting algorithm sorts the array as follows:
for (i=1; i<n; i++){
Assume A[0,..i-1] is sorted
Insert A[i] into the proper position
}
You are to write and test a program that reads in a list of floating-pont numbers from a file, sorts these numbers using the insertion sort algorithm, and writes the numbers out into another file. The input file will be formatted as follows:
n
a1
a2
a3
.
.
an
You must write, compile, and execute your program in the C++ programming language, using the GNU C++ compiler g++, on one of the Department Unix machines. You must use the <fstream.h> input-output facilities (you man not use fscanf/ fprintf instead).
Rules for submitting this (and future) programs:
All of the above should be placed in an envelope with your name and student-ID on the outside, and submitted at the beginning of class on the due date. Submissions will not be accepted after 10 minutes have elapsed from the start of class no late submissions will be accepted without documented reasons.