Chris Pollett>Old Classes>CS102, Spring 1999>Hw3

CS 102
HW#3

        Due on the web by 4pm, Thursday, March 4, 1999. Read Chapter 12 in Deitel and read to page 124 in Bailey. Then make a subdirectory of your homepage directory called hw3 (make sure you have the case right). The command to do this is cd public_html<ret> mkdir hw3 <ret>. Put your source code for this homework here. Leave the modifications on your homework so that no one can read or execute it until you want to submit the homework. When you decided to submit move into your public_html directory and type chmod -R a+rx hw3<ret>. Then under your browser find the class page and click on the homework bot to get it to collect your homework. After doing this, again in your public_html directory, type: chmod 0700 hw3 <ret>.

  1. Write an applet comb.java which has two textfields and a submit button. When data is entered in the textfields and the submit button is pressed, the applet reacts by either throwing an exception if the inputs are not a positive integers or it computes ( n choose m). The routine which catches the exception should print an error message to the applet window. (n choose m) is defined as follows:
    (n choose 0) := 1
    (0 choose m) := 0 if m > 0
    (n+1 choose m+1) := (n choose m) + (n choose m+1)
    Please do this problem using recursion. Prove using induction in a separate text file labelled comb.proof that your algorithm works. An applet for computing combinatorial. <>
  2. Write an applet sSort.java which has an editable textarea and a non editable textarea as well as a submit button. After submit is pressed this algorithm performs an insertionSort of the rows in the editable textarea using lexigraphical ordering and outputs the result in the non-editable textarea. Implement the insertionSort algorithm using recursion.
Applet to sort a textarea with user input strings.