Print Name __________________________
Signature __________________________
Dynamic Array II Lab
Individual Assignment
40 Points
2] Class Shall be called IntArray. The first array element
filled shall be element 1. Do not use element 0 at any time in this
program! Keep the ActNo accurate at all times!
| class IntArray
{ public: IntArray(long int NewMax = 10);private: long int Max, ActNo; int *Array; }; |
3] You must make at least one of the two BubbleSort improvements!
4] Fill from file, shall open the passed file and start filling the Array at element 1, until either there are no more numbers or until the quantity of numbers on the file has been exhausted. Provide an error message for the user if the passed file name is wrong! [See Sample Programs!]
5] The Sequential Search is to start by examining element 1 for the SoughtKey; if the value is found there, explicitly return 1. If not, move on to element 2; if the value is found there, explicitly return 2. If not, move on to element 3;etc. until you have exhausted the valid (ActNo) of elements. If the value is not found, return 0.
6] The Binary Search is to start by examining the middle element for the SoughtKey; if the value is found there, explicitly return the address/mid. If not, look in either the top or bottom half of the array. If the value is not found, return 0.
7] Create only two datafile for this program! Call them Data1.fil and Data2.fil. Do not create a Data3.fil!
8] Data1.fil shall contain the following data, 1 to a line:
90 100 80 70 60 10 20 50 40 30 0
9] Data2.fil shall be created, but Empty!
10] Data3.fil shall not exist!
11] Make up your own file Data4.fil; it shall contain at least 60 integer values.
12 Write a module, called TestInArray1, which shall do the following: Note the changes!
13] Write a module, called TestInArray2, which shall do the following: Note the changes!
14] Do Something That Demonstrates Your Sorting & Searching Works: Possible Solution Might Be:
IntArray
Nos(1000);
Nos.FillFromFile("Data1.fil");
Nos.QuickAndDirtyDisplay
("Unsorted Contents of Nos");
should have
90 100 80 70 60 10 20 50 40 30 0cout << "Search For First [90] =
" << Nos.SequentialSearch(90) << endl;
cout << "Search For Last [0]
= " << Nos.SequentialSearch(0) << endl;
cout << "Search For Mid [80]
= " << Nos.SequentialSearch(80) << endl;
cout << "Search For Mid [30] = " <<
Nos.SequentialSearch(30) << endl;
cout << "Search Not There [110] = " <<
Nos.SequentialSearch(110) << endl;
cout << "Search Not There [-3] = " << Nos.SequentialSearch(-3)
<< endl;
cout << "Search Not There [15] = " << Nos.SequentialSearch(-3)
<< endl;
Nos.
BubbleSort ();should have
0 10 20 30 40 50 60 70 80 90 100cout << "Search For First [0] =
" << Nos.BinarySearch(0) << endl;
cout << "Search For Last
[100] = " << Nos.BinarySearch(100) << endl;
cout << "Search For Mid [80]
= " << Nos.BinarySearch(80) << endl;
cout << "Search For Mid [30]
= " << Nos.BinarySearch(30) << endl;
cout << "Search For Too High
[110] = " << Nos.BinarySearch(110) << endl;
cout << "Search For Too Low
[-3] = " << Nos.BinarySearch(-3) << endl;
cout << "Search For Not Mid
15] = " << Nos.BinarySearch(-15) << endl;
15] Each and every program file that you turn in this semester
shall contain a documentation block at the top. Document yours!
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
///
xxxxxxx.cpp
//
///
//
/// Purpose :
//
///
//
/// Written By : Dr. Thomas E. Hicks
Environment : Linux //
/// Date
: 9/10/00
Compiler : g++
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
16] Have the main progrm call only TesArray1 module. The following line of code will execute your program and send the output to a file called Output.txt . Although you will not be able to see the prompts, enter the data specified above.
a.out > Output1.txt
17] Now change your main program to call only the TestArray2 module.
a.out > Output2.txt
g++ DynamicArray2.cpp -o MyFirstNameLastName <-- substitute your FirstLast name [all one word - capitalize the first letters! Jane Doe would do the following:
g++ DynamicArray2.cpp -o JaneDoe
18] Mail me a copy of the compiled binary file :
To:
thicks@trinity.edu
Subject: ArrayLab II
cc:
JaneDoe@trinity.edu <===send a copy to your e-mail address
Body of Message: The Array Lab II
Homework for Jane Doe is attached!
substitute your name
Attachment : JaneDoe
I shall run your program with my data files!
19] Start Windows 2000/NT/98/95. Print your programs. Set the left margin to 1 " and the right margin to .5". Make the font Courier 10 or New Courier 10. Print DynamicArray2.cpp. Print Output.txt.
20] Copy files DynamicArrays2.cpp and Output1.txt and Output2.txt to a floppy
disk.
A] Divider
B] Copy of this assignment sheet. Using an ink pen, print your name and sign this lab at the top.
C] Listing Output2.txt
D] Divider
E] Listing DynamicArrays2.cpp
F] Divider
G] Output2.txt Listing
H] Disk containing the files.