Quiz Date: Fri, Feb 7, 2003
Important note: Quiz difficulty levels will increase with each of the first few quizzes. That is, this quiz is quite a bit less difficult than future quizzes in this class.
Problem 1: State whether you are on an EVEN or an ODD computer.
Problem 2: Given the following stack of cards, what will the stack be after one full pass of the Bubble Sort algorithm?
22 27 17 24 9 60 13
Problem 3: Given the following stack of cards, what will the stack be after one full pass of the Quick Sort algorithm?
29 34 24 31 16 67 20
Problem 4: State (in 10 words or less) the difference between "print" and "println".
Problem 5: Explain (in 20 words or less) how Insertion Sort works.
Problem 6: What will the following program fragment print out?
int x; x = 2 + 4 * 3 - 1; System.out.println(x);
Problem 7: What will the following program fragment print out?
int x, y; x = 7; y = 4; System.out.println(y); y = x/2; System.out.println(y);
Problem 8: Consider the following Java program fragment:
line 1: // Java program fragment
line 2: int a, q;
line 3: // initialize
line 4: a = 11;
line 5: q = 8;
line 6: // now loop
line 7: while (a < q)
line 8: {
line 9: q = q - 1;
line 10: a = a + 1;
line 11: }
List each of the following as they occur in this fragment:
8a) All the variables
8b) All the values
8c) All the keywords
8d) The line #'s of all the declarations
8e) The line #'s of all the assignments
8f) The line #'s of all the comments
8g) All the operators
8h) Extra credit: what value will "q" have at the end of
this fragment?
Good luck!
DK
See Course Home Page.