Fall 2025 Midterm 2 Key

  1. False, True
  2. True, False, False, False
  3. Parsing, None of the above, Type-checking
  4. A: 0x78, B: 0x56
  5. leaq: rdi, 0x7fffeb04, mov: rdx (or edx), 0x916dbf59, testq: none, pushl: rsp, 0x7fffeb08
  6. False, True, True, False
  7. 1, 6, 5, 4, 2, 3, 8, 9, 11, 12, 7, 14, 16, 18, 19, 20, 15, 24, 21, 22, 23 8.
long smoothArray(int *arr, unsigned n) {
    if (n < 3) return 0;
    int sum = 0;
    for (int i = 0; i < n - 2; i++) {
        arr[i] = (arr[i + 1] + arr[i + 2]) / 2;
        sum += arr[i];
    }
    return sum;
}

Copyright © 2025 John Hott, portions Luther Tychonievich.
Released under the CC-BY-NC-SA 4.0 license.
Creative Commons License

This site uses Just the Docs, a documentation theme for Jekyll.