cs 106a february 17, 2016 answers to midterm...

6
Eric Roberts Handout #40 CS 106A February 17, 2016 Answers to Midterm Exam This midterm exam didn’t go as well as midterms have in recent years. The median was a 57 percent, which is substantially lower than what I was hoping to see. In retrospect, it’s clear that the exam was too long. Even so, it’s also clear that many of you are struggling with developing algorithms for these types of problems. The complete histogram of grades appears below. You can determine your letter grade— which I’ve curved so that the median is in the B range—by looking up your score in the table at the upper left corner of the histogram. 29 34 29 34 29 34 29 34 29 34 29 34 29 34 39 29 34 39 44 29 34 39 44 29 34 39 44 29 34 39 44 54 24 29 34 39 44 54 24 29 34 39 44 54 24 29 34 39 44 54 24 29 34 39 44 54 24 28 34 39 44 54 24 28 34 38 43 54 23 28 33 38 43 54 23 28 33 38 43 49 54 19 23 28 33 38 43 49 53 19 23 28 33 38 43 49 53 19 23 28 33 38 43 49 53 19 23 28 33 38 43 49 53 19 22 28 33 38 42 49 53 19 22 28 32 37 42 49 53 19 22 28 32 37 42 49 53 18 22 28 32 37 42 49 53 18 22 28 32 37 42 49 53 18 22 27 32 37 42 48 53 18 22 27 32 37 42 48 53 18 22 27 32 37 42 48 52 18 22 27 32 36 42 48 52 18 22 27 32 36 42 48 52 18 21 27 32 36 42 48 52 18 21 26 32 36 42 48 52 18 21 26 32 36 42 48 52 17 21 26 31 36 42 48 52 17 21 26 31 36 42 47 51 17 21 26 31 36 42 47 51 17 21 26 31 36 41 47 51 14 17 21 26 31 36 41 47 51 14 16 21 26 31 36 41 47 51 14 16 21 26 31 36 41 46 51 14 16 21 26 30 35 41 46 50 59 14 16 21 26 30 35 41 46 50 58 13 16 21 25 30 35 41 46 50 58 13 16 21 25 30 35 40 46 50 57 13 15 20 25 30 35 40 46 50 57 13 15 20 25 30 35 40 46 50 56 12 15 20 25 30 35 40 45 50 56 12 15 20 25 30 35 40 45 50 55 9 12 15 20 25 30 35 40 45 50 55 9 11 15 20 25 30 35 40 45 50 55 4 8 11 15 20 25 30 35 40 45 50 55 4 8 11 15 20 25 30 35 40 45 50 55 4 6 11 15 20 25 30 35 40 45 50 55 N = 414 Median = 34 Mean = 33.8 Range Grade N 56–60 A+ 7 49–55 A 62 43–48 A– 44 39–42 B+ 43 32–38 B 76 29–31 B– 35 26–28 C+ 30 21–25 C 47 16–20 C– 37 13–16 D 24 00–12 NP 15

Upload: others

Post on 28-Jan-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

  • Eric Roberts Handout #40 CS 106A February 17, 2016

    Answers to Midterm Exam

    This midterm exam didn’t go as well as midterms have in recent years. The median was a 57 percent, which is substantially lower than what I was hoping to see. In retrospect, it’s clear that the exam was too long. Even so, it’s also clear that many of you are struggling with developing algorithms for these types of problems. The complete histogram of grades appears below. You can determine your letter grade—which I’ve curved so that the median is in the B range—by looking up your score in the table at the upper left corner of the histogram. 29 34 29 34 29 34 29 34 29 34 29 34 29 34 39 29 34 39 44 29 34 39 44 29 34 39 44 29 34 39 44 54 24 29 34 39 44 54 24 29 34 39 44 54 24 29 34 39 44 54 24 29 34 39 44 54 24 28 34 39 44 54 24 28 34 38 43 54 23 28 33 38 43 54 23 28 33 38 43 49 54 19 23 28 33 38 43 49 53 19 23 28 33 38 43 49 53 19 23 28 33 38 43 49 53 19 23 28 33 38 43 49 53 19 22 28 33 38 42 49 53 19 22 28 32 37 42 49 53 19 22 28 32 37 42 49 53 18 22 28 32 37 42 49 53 18 22 28 32 37 42 49 53 18 22 27 32 37 42 48 53 18 22 27 32 37 42 48 53 18 22 27 32 37 42 48 52 18 22 27 32 36 42 48 52 18 22 27 32 36 42 48 52 18 21 27 32 36 42 48 52 18 21 26 32 36 42 48 52 18 21 26 32 36 42 48 52 17 21 26 31 36 42 48 52 17 21 26 31 36 42 47 51 17 21 26 31 36 42 47 51 17 21 26 31 36 41 47 51 14 17 21 26 31 36 41 47 51 14 16 21 26 31 36 41 47 51 14 16 21 26 31 36 41 46 51 14 16 21 26 30 35 41 46 50 59 14 16 21 26 30 35 41 46 50 58 13 16 21 25 30 35 41 46 50 58 13 16 21 25 30 35 40 46 50 57 13 15 20 25 30 35 40 46 50 57 13 15 20 25 30 35 40 46 50 56 12 15 20 25 30 35 40 45 50 56 12 15 20 25 30 35 40 45 50 55 9 12 15 20 25 30 35 40 45 50 55 9 11 15 20 25 30 35 40 45 50 55 4 8 11 15 20 25 30 35 40 45 50 55 4 8 11 15 20 25 30 35 40 45 50 55 4 6 11 15 20 25 30 35 40 45 50 55

    N = 414 Median = 34 Mean = 33.8 Range Grade N 56–60 A+ 7 49–55 A 62 43–48 A– 44 39–42 B+ 43 32–38 B 76 29–31 B– 35 26–28 C+ 30 21–25 C 47 16–20 C– 37 13–16 D 24 00–12 NP 15

  • – 2 –

    Problem 1: Karel the Robot (10 points) There are many strategies you can use to solve this problem. The code on this page takes advantage of the fact that Karel can determine whether it is searching for a beeper pile or distributing beepers by checking whether it has beepers in its bag.

  • – 3 –

    Problem 2: Simple Java programs (10 points) (2a)

    10 * 9 + 8 * 7 * 6 * 5 + 4 * 3 / 2 * 1

    1776

    Character.isDigit((char) 9)

    false

    2 + 0 + "1" + '6' "216"

    (2b) Calling mystery("driven") returns "everdeen" (2c)

  • – 4 –

    Problem 3: Simple Java programs (15 points) The following solution uses arithmetic operators to isolate the digits; the problem is slightly easier to solve if you convert the integer n to a string first.

    Problem 4: Using the graphics and random number libraries (15 points) This code uses growCircle from Section #3 (Handout #24A).

  • – 5 –

  • – 6 –

    Problem 5: Strings and characters (10 points)