Frequently Asked Questions (FAQ) Last modified: Fri Feb 4 04:25:41
CST 2000
An important part of learning how to create robust programs is in learning how to create good test cases. We've made things a little easier for you by outlining a list of problems that you could encounter and that you should think about.
You will not be able to see ahead of time the test files that we will run on Wednesday.
The project lets you work on not only creating threads but also the data communication between the threads, although it is still on a very simple stage. In the second project, you will face a more complex communication problem. If all of the keys fit in main memory, it is more efficient to keep them in memory rather than writing them out to the (very slow) disk.
You need to actually merge the sorted runs. As stated in the specification, one approach is to have a single thread compare the first key in each run, pick the minimum key, copy it to the output list, and remove that key from the top of its run. If this step is repeated until all keys have been removed from every run, the output list will contain all of the keys in sorted order.
If a line does contains any white space, you can flag that as an error. As with all errors, you should print out the filename, the linenumber, and the contents of the line. (You might find that surrounding the contents of the line with quotes when you print it out is helpful for seeing if whitespace or a carriage return is being included in the string.)
Q7: How to open a file to read or write
in Java?
A:
Various Classes and Methods are defined in Java to deal with file input and output. Sometimes it is a little bit confusing. If you have
difficulties in this, please go to the course website and take a look at the tutorial written by Prof. Solomon, Java for C++ Programmers. In the part "Input and Output", you may find some examples. It would be helpful.But the example given for writting a file doesn't check whether the file has existed or not. You may go to the Java API webpage and look at the File class. It might be able to give you a hint about how to do the checking. If you have another way to do it, it is fine as long as it works.