CmpE130 Lab Projects
Labs should be submitted using the UNIX utility providedsource code and makefile. Currently the submit utility is named submit2. Typing the command by itself will give instructions on how to use it.
The resulting executables must be named exactly as required by the problem specification. Command line arguments must be taken as specified in the assignment. Programs with non-standard names or interfaces will not be accepted.
Grading is done using a script. If your code does not meet the requirements of the script, it will not be graded.
For some reason, many students do not appear to be testing their makefile before submission. This is not a good idea. It is very easy to test a makefile. Simply type make.
All labs must be done individually. Any use of existing code taken from books or on-line sources must be properly cited. It is not acceptable to copy code from other students. The university policy can be found at http://www.sa.sjsu.edu/download/judicial_affairs/Academic_Integrity_Policy_S07-2.pdf.
Resubmission of labs:
- Test your code before you submit it. Submission of code is not a debugging mechanism. If you are having trouble getting your code working properly, bring it to my office hours.
- One regrade only per assignment is permitted. Late penalty will be enforced.
- Submit your code again and send me an email requesting a regrade. I have no other way of knowing when you resubmit.
Lab 1
- Lab 1 (corrected 2 Sept. 2009)
Here is the example I went through in class:

The following references may be useful:
- make files
- more make files
- An Introduction to the UNIX Make Utility
- You can find lots more tutorials like these using Google...
Lab 2
Some people in previous semesters asked how to satisfy the requirement for writing the entire data object at once using stream-oriented I/O. There are probably many solutions, but the following is one that appears to work:
MyOutputFile.write((char*) &MyDataRecord, sizeof(MyDataRecord));
Don't try to write C++ standard strings this way. It doesn't work. (They don't have a known size.) C strings, structs or non-dynamic class objects should work fine, though.
Lab 3
Do you have questions about having multiple executables in one make file? Here is an tutorial. The first rule in the makefile is the default. That should be the one that has all the other individual rules as its dependencies.
Suggested structure:
- Binary search in index
Given a key, the function returns two values, a location in the index and a Boolean value indicating whether the key was found in the index. The binary search should print each index location accessed (on one line, please!). - Insert into index
Since the binary search has already found the correct location, this value can be passed to the indexinsert function along with a key and RRN. Following entries in the index are moved down to make room for the new entry. The function should print the range of index entries which are being moved (first and last only). - Delete from index
Since the binary search has already found the correct location, this value can be passed to the indexdelete function. Following entries in the index are moved back to remove the index entry. The function should print the range of index entries which are being moved (first and last only).
I suggest that common functions should be placed in an include file.
Deadline extended to Nov. 22.
Lab 4
B-Tree code from second edition of textThis is a good example to use to see how to structure your code, especially if you are going to write your lab in C. The text (new edition) gives examples in C++, but the algorithm is not the one you should use.
There is one error in the code, if you download it from the link above. In the function create_tree( ), after the statement key = getchar( );, add the statement putroot(NIL); This is just to create an empty header record. Otherwise, the header record for the B-tree file is not written correctly on initialization.
There is a correctly running version of this code available on aala0895.
Lab 5
- Lab 5
Updated from original posted version.