return to lecture index
15-200 Lecture #12 (September 28, 2005)

Test Back Today

Ok so we knew the test was long, so we either graded 5 or 6 which ever one was better. If you blew question 5 we graded question 6 if you blew question 6 we graded question5. Originally we thought the grades were dismal so some of you heard rumors of a retest, but after I went through them they were very typical.

Scores looked like this:

out of all 58 students 24(80-100)/58 are on track for getting an A in the course
out of all 58 students 15(70-79)/58 are on track for getting a B in the course
out of all 58 students most of the rest are on track for a C with a few lower exceptions. Remember test grades are used to deflate your average because most people will have a 100 on the final and a 95 average on the labs.

The people who get below 40 on an exam aren't credible grades, especially if they have not come to see the TA's

There is only a handful of people who are at risk across the sections but we can work with that and get them help.

Going over the exam

Lets go over the exam a little bit here.

#1 what does an algorythms Big-O mean?
It tells us how the algorithm performs for a very large number of items

#2 Three different classes coincidentally have four methods with the same signiture. Is it prudent to define an Interface to capture this commonality?
They have to have commonality in order for them to make sense to be put in an interface. You want an interface when you have common operations, the methods do the same thing to the different data structures.

#3 Why would one prefer to design software using an interface?
First it lets them change the data structure underneath. And if the small problem turned into a larger problem they could change the under lying code without changing the software. Ability to write genereic algorithms and ability to switch underlying data structure are the two key points we were looking for.

#4You are given a large list of names one at a time, do you choose LinkedList or ArrayList?
The trick is we are given the names one at a time. We have to have an insertion sort. The second thing is that it is a very large list of names. So if it was an ArrayList we have to push the rest of the items back in an ArrayList. We still have to traverse to find it but Array List has an O(n) insert and LinkedList O(1) so clearly linkedlist wins.

#5 implement pubic void removeLastOccurence (Object o) on a singlyLinkedList

public void removeLastOccurence (Object 0){

// Empty List
if(head == nul)
 return;

// search for it
Node index=head;
Node candidatePred = null; 
 while(index.getNext() !=nll) {

  if( index.getNext().getItem().equals(o))
     candidatePred=index;

  index = index.getNext();
 }

// check to see if we found the last occurence
 if(candidatePred !=null){
    
    if(candidate.getNext()==tail)
	tail=candidatePred;   


   candidatePred.setNext(candidatePred.getNext().getNext())
   count--
   retun;
 }


  // if it was the head
  if(get.getItem().equals(o)) {
   head = head.getNext();
   count --;
  }


  if(head == null)
   {
      tail = null;
   }

  count--;
}

#6 Complete the ReversableList class skeleton


class ReversableList {

 private List words;
 private int count;

 public ReversableList(){
   words = new ArrayList(); // or LinkedList or Vector
   count = 0;
 }
 
 public ReversableList (Iterator words) {
  
   this.words = new ArrayList(); // or linkedlist or vector
   count = 0;

   while(words.hadNext()){
      this.words.add(words.next());
      // or this.words.add(count++, words.next());
    }   

 }

 public void addWordAtTail(String word){
   this. words.add(word);

   // or this.words.add(count++, word);

 } 

 public ReversableList reverseCopy() {

  ReversableList  newRlist = new ReversableList();

  Iterator wordIterator = words.listIterator();
 
  while(wordIterator.hasNext()) {
   newRList.words.add(0,wordIterator.Next());
   newRList.count++;
  }
 
  return newRList;
 
}

Remeber you can always come talk to Kesden or one of the TA's. We are all here to help with any questions you have.