midterm-2-recitation-solutions

midterm-2-recitation-solutions - CSE 114 Midterm Exam 2...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 114 Midterm Exam 2 (recitation version) – SOLUTIONS Wednesday, March 29, 2006 NAME (please print legibly): Your University ID Number: Your Recitation Number: Please leave at least one seat between yourself and the person next to you. No books or notes can be used during the exam, except for your “cheat sheet”. Any CHEATING will result in an F as well as being written-up on academic dishonesty. The last page contains a summary of some useful methods. NO BS bonus: If you do not know the answer to a problem and leave it blank you will receive 1 point for each sub-part (e.g., a,b,c, etc.) that you leave blank. If you write anything in the space and it is wrong, you will receive a zero. Thus, the score for a completely blank exam is XX. Not all questions are of equal difficulty/points value, so read through the entire exam before beginning! QUESTION VALUE SCORE 1 10 2 5 3 15 4 15 5 15 6 5 7 20 8 15 TOTAL 100 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1. (10 points) The array below is to be sorted using insertion sort. Fill in the contents of the array after each step in the insertion sort algorithm. START: [ 412, 194, 66, 38, 7, 290, 994, 81, 361, 199 ] [ 194, 412, 66, 38, 7, 290, 994, 81, 361, 199 ] [ 66, 194, 412, 38, 7, 290, 994, 81, 361, 199 ] [ 38, 66, 194, 412, 7, 290, 994, 81, 361, 199 ] [ 7, 38, 66, 194, 412, 290, 994, 81, 361, 199 ] [ 7, 38, 66, 194, 290, 412, 994, 81, 361, 199 ] [ 7, 38, 66, 194, 290, 412, 994, 81, 361, 199 ] [ 7, 38, 66, 81, 194, 290, 412, 994, 361, 199 ] [ 7, 38, 66, 81, 194, 290, 361, 412, 994, 199 ] FINISH: [ 7, 38, 66, 81, 194, 199, 290, 361, 412, 994 ] 2. (5 points) Which of the following is an advantage of arrays over ArrayLists ? (a) Arrays can hold either primitive types or objects (b) Arrays can grow and shrink as needed (c) Array elements can be accessed directly by position (d) None of the above ANSWER: A 2
Background image of page 2
3. (15 points) Fill in the body of the isSorted() function below. This function takes an array of integers
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

midterm-2-recitation-solutions - CSE 114 Midterm Exam 2...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online