Name & ID:_________________________________________________________

Quiz Q5

CS 100 – Summer 1999

Due: Monday July 26, 1999 10 minutes after the beginning of class

Question 1: Thinking in Matlab right now, what will the variable a look like after the following statement is executed: a = 10 * [0:9]

 

 

 

 

 

 

 

Question 2: Thinking in Java (this class is now officially bi-lingual!), what will be the output of the following program. (Be very, very careful.)

public class TrivialApplication {

public static void main(String args[]) {

int x = 1;

int y = 2;

C c = new C();

c.myMethod(x, y);

System.out.println("x = " + x + " y = " + y);

}

}

public class C {

public void myMethod(int x, int y) {

x = 3;

y = 4;

}

}

 

 

 

 

 

Question 3: Thinking algorithmically: describe the quicksort algorithm in 2 or 3 clear sentences.