H212 Introduction to Software Systems, Honors

    Final Exam

    You have two hours. There are 100 points total (budget about a minute per point). Be sure to write your name on each sheet of paper you turn in. You may use your any printed reference material you choose, or the computer, but not anyone's help. Use good coding style and proper indentation. Check your work thoroughly. Good luck!
     
    1. (10 points) Describe the software development model your group used in its project in standard terminology (text section 11.1). What were the pros and cons of this model in your experience? If you had it to do over again, would you use the same model? If you had time to devote four times as much effort to the project, would you approach it with a different model?

    2.  
    3. (10 points) Describe the object-oriented design methodology your group used in its project in standard terminology (text section 15.1). What were the pros and cons of this methodology in your experience? If you had it to do over again, would you use the same methodology? If you had time to devote four times as much effort to the project, would you approach it with a different methodology?

    4.  
    5. (15 points) Refer to the Sort.java link on the course home page (or the handout of that page).
      1. Suppose "+1" was omitted in the last line of the quicksort method. Would the algorithm still work? Be specific.
      2. Implement as concisely as you can a class RevIntegerVector that is like Sort.IntegerVector but reverses the direction of the sort. Of course you may use Sort in your implementation.
       
    6. (15 points) Refer to the ThreadedEchoServer.java link on the course home page (or the handout of that page).
      1. When do threads die in this server? What happens to their memory when they die? Why doesn't this happen sooner?
      2. Modify the server so that each line echoed contains the number of active clients, rather than the id number of the current thread.
       
    7. (50 points) A ring data structure consists of a number of elements arranged in a circle. (This is a very useful data structure that can be used to easily implement sequential linked structures such as lists, stacks, and queues, as well as direct use as a ring, and allows sequences of elements to be spliced together or separated at any point.) Any element in a ring may be used to represent the ring. The left and right of an element are as viewed from the center of the circle. When two rings are joined, their representative elements become adjacent in the resulting ring and the elements that are disconnected in the process are joined. A singleton ring has only one element.
    8. Implement this data structure as a class Ring with the following public methods:

      • Ring(Object value) : constructor that returns a new singleton ring containing the given value.
      • Object value() : returns the element's value.
      • Ring fromArray(Object[] array) : returns a ring containing the elements of array in array order beginning with the returned element and proceeding clockwise. Throws Ring.Exception if the array length is zero.
      • void join(Ring r) : join r to the right (of the current element).
      • void insert(Object value) : inserts a new ring element with the given value to the right.
      • Ring left() : returns the element to the left.
      • Ring right() : returns the element to the right.
      • String toString() : returns a string of the form "Ring[S1, S2, ..., Sn]", where S1,...,Sn are the string representations of the values of the elements of the ring in clockwise order, starting with the current element.
      For example, the Ring class might include the following test method, where as usual comments on print statements indicate printed values. (Of course you needn't repeat this method in your solution.)

          public static void main(String[] args)
                  throws java.io.IOException, Ring.Exception {
              String[] abc = {"a", "b", "c"};
              Ring a = fromArray(abc);
              System.out.println(a); // Ring[a, b, c]
              Ring d = new Ring("d");
              Ring f = new Ring("f");
              d.join(f);
              d.insert("e");
              System.out.println(d); // Ring[d, e, f]
              a.join(d);
              System.out.println(a); // Ring[a, d, e, f, b, c]
              System.out.println(d); // Ring[d, e, f, b, c, a]
              a.join(f);
              System.out.println(a); // Ring[a, f, b, c]
              System.out.println(d); // Ring[d, e]
              System.in.read();
          }

       (With my usual indentation style, 46 lines including blanks does it.) Should your solution be incomplete or incorrect, a good deal of partial credit will be awarded if you show your work. Certainly show pointer diagrams, without which it's hard to imagine anyone figuring this one out!
       


Chris Haynes / chaynes@indiana.edu