Programming and Problem Solving using C - Winter 2008 Gusfield

  • This index page will just link to the various course handouts that are available on the web, and provide some description of them.

    Distribution List

    1. Matloff's tutorial page In week one, read Matloff's tutorials on Unix (at least the sections titled `if you have no Unix background at all' and 'the Unix file system'), and if you need a Unix based editor, read the tutorials on Vi, Vim and/or emacs. These are pdf files which should download to your computer. If you want to install linux on your pc, read those pages.

    2. There are three computer labs in CSIF, in the basement of Kemper Hall, that have computers for your use in this class. Everyone who is enrolled should have a computer account set up for the computers in the CS Instructional facility (CSIF) in the basement of Kemper Hall. Go to the glass window opposite room 83 to look up your user name - usually just your last name. Your initial password is the last 8 digits of your student ID (which has nine digits). If you want to change your password, and you should want to, read the man file for the Unix command yppasswd (type man yppasswd), to learn more about the command. Help is available in room 47 for using the labs. Note that this help is for using the labs, not help with CS 30. For specific help with CS 30, you need to see one of the course TAs.

    3. You may also log into the CSIF machines remotely (details can be found at UCDAVIS computer science at home ). Or you can work on any other machine that has Unix, and a C compiler for writing C programs, and internet access. NOTE: Different systems (operating systems, computer type, configurations, libraries etc.) can behave differently, so a C program written on one machine and system might not behave the same on a different machine or system (an ugly reality!). You may find it more convenient to do most of your work at home, or in another lab, BUT before handing in your program, you must make sure it works correctly on the machines in the CSIF. Those are the machines we will use when we compile, run and grade your programs. If your programs don't run correctly there, it will not matter to the grader that they ran correctly elsewhere. It is your responsibility to port your programs in time to the CSIF and test them there. It will not be a legitimate excuse that the connection to the CSIF was down just before the assignment was due. Also, we (Professor Gusfield and the TAs) can only give very limited help on problems you encounter on machines and systems outside of the CSIF, and how to set up the software to work at home, or connect to the CSIF remotely. Campus IT staff and the CSIF staff can also help somewhat on those issues if you run into problems.

    4. Unless stated otherwise on a homework assignment, all assignments are meant to be done individually. Of course you can discuss some aspects of the assignment with others, particularly what the assignment asks for, but each student is expected to individually figure out how to set up the program, how to use the correct parts of C in the program, and how to write and test the program. If you have any questions about the degree of individuality that is expected, please ask. We may routinely run all the submitted homework programs through a utility that finds pairs of programs that are ``too similar". We really don't like dealing with situations when we find such a pair of programs, so please design and write your programs yourself. Also, you will learn much more that way, and be better prepared for exams.


    5. Discussion sections (Weds. and Thurs.) WILL be held this week (Jan. 9, 10) as scheduled. HOWEVER, for this week only, they will be held in the CSIF computer labs in the basement of Kemper Hall. Those are rooms 67 and 75 (come to room 67 first) in Kemper Hall. The are to help you get going on your first assignment and on logging in etc. If you take a look at the assignment and think you need the help, please come to your assigned discussion section, so we don't have too many people at any one.
      Also, TAs will be in those rooms on Wed., Thurs, and Friday evenings from 6-7 pm, this week only, to help with the first assignment.
    6. After the first week, all the discussion sections will be held in their scheduled classrooms, rather than in the Kemper Hall computer labs.

    7. Brief Course Syllabus in pdf
    8. Instructions on how to Script an interactive session
    9. Instructions on how to use the utility handin

    10. TA office hours: Monday 1-3, Tuesday 5-8pm, Weds. 3-6 and also 6-9, Thursday 3-4 (this changed Jan. 10)
      The TA's will be in Room 53 Kemper Hall (in the basement), or in one of the CSIF labs helping students. If they are in a lab, they will leave a note in 53 Kemper.

    11. First Exercise, due by Tuesday. Jan. 15, 11:59pm. First Exercise
    12. Professor Gusfield's Office Hours will be posted shortly. 2125 Kemper Hall, or by appointment.
    13. The first midterm will be on February 7. The second will be scheduled later.
    14. The final exam will be March 19, 8:00 - 10:00 am as stated in the Winter 2008 class schedule and registration guide. Plan carefully. No early or late exams will be given.
    15. The following programs will be discussed on Jan. 15.
      pun.c
      pun1.c
      pun2.c
      pun3.c
      pun4.c
      celcius.c
      dist.c
    16. Starting the week of Jan. 14, the discussion sections will be held in their originally scheduled classrooms, not in the CSIF computer labs.
    17. Second Homework, due by Wed. Jan. 23, 11:59pm. Second Homework
    18. The following programs were discussed on Jan. 17.
      floatproblem.c
      doublefloat.c
      io.c
      stock.c
      molar.c
    19. Jan. 22, 2008 I fixed a typo (cel2cript to cel2script in Problem 3) in HW 2. Since it is important that your files be names as specified (and expected) please be sure to name your script file cel2script, but don't worry about it if you have already handed in your script file and called it cel2cript instead of cel2script.
    20. The following programs were discussed on Jan. 22.
      stock1.c
      stock2.c
      equaltest.c
      badequaltest.c
      ifandsshort.c
      ifands2.c
    21. Professor Gusfield's Office hours will be Mondays 5:15 - 6:15 and Thursdays 4-5, or by appointment.
    22. Program ifandshort.c has been updated (Jan. 23) so that for any number entered (1 through 8) the printed deductions precisely locate the number. Previously, once the number had been deduced by the program, the last explicit deduction had not been printed.
    23. The following programs were discussed on Jan. 24:
      tall.c
      broker.c
      testdowhile.c
      whiletest.c
      numdigit.c
    24. Third Homework, due by Thursday . Jan. 31, 11:59pm. Third Homework

    25. URGENT: PLEASE READ: Jan. 28, 6:15. We just started testing an automated grading program for HW 2. It has INCORRECTLY written to all students that it cannot find their HW 2. We know this is an error and will correct it shortly. So please do not be alarmed. There is also no need to write to us about this. We are sorry for any panic it caused.

    26. If you submitted the source code for HW 2 but did not get an email from us with results (although there may not be any stated grade in that email), please write to freemalloc@yahoo.com
      If you submitted executable code for HW 2 (about 15 students did this) and you have not gotten email about this, please write to pchowdhury@ucdavis.edu
      In either case be sure to include the user name on your CSIF account, the directory that you used when you handed in HW 2, and your email address.
    27. The following programs were discussed on Jan. 29:
      square2.c
      loop1.c
      loop2.c
      pyth.c
      pyth1.c
    28. An explanation on how to find the matching brackets in a program.
    29. First midterm from winter 07 This is midterm 1 from the CS30 class I taught last year. The figure for the first question is missing, but you can understand the **type** of question it is. The midterm this year might be a little longer since the class this year is a T,Th class, and last year the students only had 50 minutes.
    30. The following programs were discussed on February 1.
      breakloop.c
      prime.c
      checking.c
      checkingchar.c
      testgetchar.c
    31. Fourth Homework, due by Tuesday. Feb. 12, 11:59pm. Fourth Homework

    32. Sorry, Professor Gusfield will be out of the office on monday Feb. 4, so will not have office hours Feb. 4.

    33. Sorry again, Professor Gusfield will be out of town on Thursday Feb. 8, so will not have office hours Feb. 8.

    34. The midterm on Thursday Feb. 7 will be open book and notes. It is also suggested that you bring copies of programs distributed through the class website. No bluebooks will be required. The midterm covers everything discussed in class, and the readings in the book through chapter 7.

    35. The protections on the source code (the .c files) on the csif machines, for the programs on HW 2 and 3 has now been set so that you can see the source code.

    36. The following programs were discussed on February 5.
      reverse.c
      repdigits.c
      interest1.c

    37. solutions to the sample (2007) midterm
    38. twin prime update - contrary to what was written in the original homework 4 writeup, 9 is not a prime number. The hw 4 writeup has been modified to correct that brain hiccup.
    39. The executable for prettyline can be executed on a csif machine by typing
      ~gusfield/cs30w08/prettyline
      It has been reported that my program does not do the right thing if one puts in spaces after the last non-space character on a line (i.e., before the return). So, don't use such lines in your test input (I guess I didn't). If your program does not have that problem, don't change it to have that problem. In other words: "do what I say, not what I do".
    40. The programs discussed in class Feb. 12:
      array.c
      array1.c
      drunk.c
      deal.c
      deal1.c This is a modified version of deal.c needed for HW 5.
    41. Statistics for the first midterm:
      Max possible: 125, Max obtained: 125 (yes, it used to say 124, but that was an error), Mean : 93.6, Median: 100, std dev: 20.6, total number of scores: 158
    42. Fifth Homework, due by Thursday Feb. 21, 11:59pm. Fifth Homework
    43. Midterm Solutions: Midterm Solutions (most of them)

    44. The executables for walk and walk5000 are available for execution. Download the instructions for the fifth homework for details. Also, the instructions have been slightly modified for the walk program. Read the instructions for details.
    45. The programs discussed in class Feb. 14:
      valuetest.c
      sumarrayexecution.c
      average.c
      testcope.c
    46. A student just pointed out that unless the correspondence between the numbers 0, 1, 2, 3 and the legal moves in program walk.c are the same in my and your program, we will not get the same results. In my program 0 corresponds to up, 1 to left, 2 to down and 3 to right.
    47. The solution programs from HW 4:
      twinprimes.c
      prettyline.c
    48. The programs discussed in class Feb. 18:
      functiontest.c
      isort.c
      power.c

    49. Mini-Midterm Feb. 28. As I announced in class yesterday, there will be a mini-midterm covering chapters 8,9,10 on Feb. 28. with emphasis on arrays and functions. There is not much new material in Chapter 10, and we will cover it quickly in the next lecture. The midterm will only be 45 minutes long, so we can have a partial lecture on Feb. 28 also.
    50. David Camp will try to have extra TA office hours Thursday, Feb. 21 from 5-7
    51. The programs discussed in class Feb. 21:
      binary1.c
      qsort.c
    52. Sixth Homework, due by Friday Feb. 29, 11:59pm. Sixth Homework
      binary2script
      infile
      I said in class yesterday that this homework would require you to write a recursive program for binary search, but later I decided against that. It is still a good exercise for you to consder doing sometime.
    53. The solution programs from HW 5:
      walk.c
      permute.c
    54. Two sample array problems for midterm 2: array problems
    55. The executable version of funarr (for HW 6) can be run on any csif machine by typing: ~gusfield/cs30w08/funarr
      You can also make an infile and use redirection to reduce your typeing when working on your version of funarr.c
    56. The programs discussed in class Feb. 25:
      static1.c
      external.c
      pointer.c
      decompose.c

    57. The solution programs from HW 6:
      binary2.c
      funarr.c
    58. The programs discussed in class Feb. 28:
      fwsum1.c
      wpsum.c
      maxp.c
      decomposepp.c

    59. The programs to be discussed in class March 3:
      lettersp.c
      stest.c
      printnames.c
      raggedarray.c
      raggedarray2.c
    60. NOTE: Now that we only have four lectures left, we will be going faster in lecture. Also, now that we are discussing pointers and arrays, the material is more confusing than before. Therefore, I strongly advise people to attend the lectures. I know that up to now, many people have been able to follow the class up to now just by reading the class website, looking at the programs presented in each class, doing the HWs etc, but I think that will be more difficult to do from here on.
    61. Seventh Homework, due by Monday March 10, 11:59pm. Seventh Homework
    62. Tutorial on gdb and ddd Teach yourself the basics of the gdb debugger and debugging. At a minimum learn how to list, execute one line at a time, set and unset breakpoints, print variable values. The use of a debugger is often essential. gdb is available on most unix based systems. ddd is a GUI based on gdb. Use it if you have it.
    63. The executable for problem 4b (part of HW 7) can be run on a csif machine by typing
      ~gusfield/cs30w08/bb4
    64. The programs discussed in class March 6:
      ps3.c
      ps4.c
      ps5.c
      i3stringsort.c
      stringidiom.c

    65. The programs needed for HW 8, to be discussed in class March 11:
      readline.c
      invent.c
      readline.h
    66. Eighth Homework Due Monday March 17, 11:59 pm.
    67. The programs discussed in class March 11:
      structarr.c
      structexample.c
      structexample1.c
      students.dat Small data file for use in structexample1.c
    68. The programs discussed in class March 13:
      dataprint.c
      m3stringsort.c
      sorter.h
      malloconed.c
      malloctwodbracket.c
      malloctwod.c
    69. The final exam will be open book and notes, exactly as in the midterms (no laptops or neighbors - if the person sitting next to you has the same name, first or last, please move). All material from the entire course is fair game, but the emphasis will be on material since the second midterm. The material since the midterm is covered in: All of chapter 13 (except command line arguments); 15.1, most of 15.2, p. 320 - 322 on makefiles; 16.1, 16.2, 16.3; 17.1, 17.2, 17.3 (but I didn't mention realloc in lecture), p. 368, 369 of 17.4 (the free function); I briefly mumbled somthing about linked lists (section 17.5) at the end of the last lecture. I won't include that on the exam, but you should read 17.5 if you are going on to cs 40 (or if you just want to know about linked lists).
    70. The CS30 final exam from Winter 2007 final 2007. At least two problems in that exam were based explicitly on programs seen in that class, and so they will probably seem much harder to you then they did to the 2007 class. So don't panic if this exam seems very hard. Also, there is a question about recursive programs on the 2007 exam, but we did not go into recursion as heavily this year, so I will not ask such a hard question about recursion on the 2008 exam. However, some question about recursive programs is fair.
    71. Programs solving HW 7
      bb4.c
      raggedarray3.c
    72. Program solving HW 8
      inventextra.c This should be compiled as: gcc inventextra.c readline.c -o inventextra, but right now it is having a compiling problem. Still you can study the code to see how the solution works.
    73. Detailed notes on the book and course, compiled by Pooja Deopura, a student in CS30. Thank you Pooja!