CSE 142, Autumn 2011
Midterm Exam: Friday, November 4, 2011
Name:
_
Section:
_ TA: _
Student ID #:
_
You have 50 minutes to complete this exam.
You may receive a deduction if you keep working after the instructor calls for papers.
This exam is open-book.
CSE 142 Sample Final Exam #8
(based on Summer 2009's final; thanks to Victoria Kirst)
1. Array Mystery
Consider the following method:
public static void arrayMystery(int[] a) cfw_
for (int i = 1; i < a.length - 1; i+) cfw_
a[i] = a[i + 1] + a[i - 1];
In
CSE 142 Sample Final Exam #6
(based on Summer 2008's final; thanks to Hlne Martin)
1. Array Mystery
Consider the following method:
public static void arrayMystery(String[] a) cfw_
for (int i = 0; i < a.length; i+) cfw_
a[i] = a[i] + a[a.length - 1 - i];
CSE 142 Sample Final Exam #4
(based on Winter 2008's final)
1. Array Mystery
Consider the following method:
public static void arrayMystery(int[] a) cfw_
for (int i = a.length - 1; i >= 0; i-) cfw_
if (a[i] = a[a.length - i - 1]) cfw_
a[i]+;
a[a.length -
CSE 142 Sample Final Exam #3
(based on Autumn 2007's final)
1. Array Mystery
Consider the following method:
public static void arrayMystery(int[] a) cfw_
for (int i = a.length - 2; i > 0; i-) cfw_
if (a[i + 1] <= a[i - 1]) cfw_
a[i]+;
Indicate in the r
CSE 142 Sample Final Exam #2
(based on Winter 2005's final; thanks to Stuart Reges)
1. Array Mystery
Consider the following method:
public static int arrayMystery(int[] array) cfw_
int x = 0;
for (int i = 0; i < array.length - 1; i+) cfw_
if (array[i] > a
CSE 142 Sample Final Exam #1
(based on Spring 2005's final; thanks to Stuart Reges)
1. Array Mystery
Consider the following method:
public static void arrayMystery(int[] a) cfw_
for (int i = 1; i < a.length; i+) cfw_
a[i] = i + a[i - 1] - a[i];
Indicate
CSE 142, Autumn 2011
Final Exam
(key at end)
1. Array Mystery
Consider the following method:
public static void mystery(int[] a) cfw_
for (int i = 1; i < a.length - 1; i+) cfw_
a[i] = (a[i - 1] + a[i + 1]) / 2;
Indicate in the right-hand column what val