To do the timing, I just added all that is needed to the provided makefile. (Thus you may want to get a new copy of it from the course account.) For timing the divide-and-conquer routine you can use the provided "timing-ex.cc". The only change needed there is to change the call to closest_pair to have the argument structure required by your routine. (Also change the prototype at the top of the file.) Then type "make timing-ex". After successful compilation and linking it will create "timing-ex.out" that you can run.
For timing the naive routine you are to put the main routine in a file called time-naive.cc. You can copy timing-ex.cc (e.g. in UNIX type cp timing-ex.cc time-naive.cc) and then edit time-naive.cc. Notice that the sort routine is no longer needed and thus the calls to it (and the prototype at the top) should be removed. Place your implementation of the naive algorithm in "naive-closest-pair.cc". Then just type "make time-naive" to create "time-naive.out" which you can run.
For the sake of debugging, ease of grading, and simplicty the seed used for the random number generator is always 0. Thus every time you run your program you get the same sequence from which the points are drawn. In lab 3, I will show how you can give a seed to the random number generator (or even seed it with the time for the system clock). If you are interested in how to do that I can tell you now. Also, notice that if you made a loop that generated say 3 point sets of the given size, then you would get 3 different point sets (albeit the same 3 each time you ran the program).
If you have further questions let me know.
If you need help finding the labs the CEC home page has all the needed information. Check out "What's New?" and "Labs and Schedules"
2nd Best Option: Go to the Pentium PC lab. Log ontothe PC and choose wither "eXceed 4 rooted window" or "eXceed 4 local window from the "Sessions" folder. The rooted window will open a window just like an X-term, and the local window willmx X clients with PC windows --- Try them both. For more information on starting a unix session from a PC look at the PC section on the CEC Frequently Asked Questions page.
Last Option: Go to the MAC lab. Note that if you are going to use the debugger then you need to start a MacX session (which is not even currently available). Furthermore, the debugger differentiates between the three mouse buttons and the Macs just have a single mouse button. They are also slower than the other options.
NOTE: If you are having trouble copying files directly from the WEB (e.g. if you are on a MAC), you are best copying the provided files using the unix copy (cp) command as described on the Unix help page. Even if you are working in the SPARC or Xterm lab, I think you'll find it faster to use this option.
Correction for problem 4b: In the hint change floor(n/2) to ceiling(n/2)
Return to the CS 241 Home Page