Midterm

Midterm Policies

Date: Monday, July 29, 2019 (in lecture)
Time: 10:50am - 11:50am (60 minutes)
Location: Sieg 134

You will be provided with:
  • Reference Sheet: We will provide a copy of the with your exam.
  • Printed Exam with Scratch Paper: Your exam will have extra blank paper for you to use if necessary. If you do use a blank page for a question, you must clearly make a note of that under the corresponding question. Otherwise, your work may not be graded.
  • Timekeeping (we will project a large clock at the front of the room)
You should bring:
  • Pencil/Pen
  • Eraser
  • Notes Sheet: You may bring up to ONE 8.5 x 11 inch sheet of paper, double-sided, with handwritten or printed notes.
You are NOT allowed to use/wear during the exam:
  • Hats or Sunglasses
  • Cellphones, Calculators, or any other electronic device

Midterm Topics List

In general, material from: lectures/sections/exercises up to but NOT including C++ templates/STL, and homeworks up through HW2 is fair game on the midterm.

Program Organization

  • System layers: C language, libraries, and operating system
  • Building an executable: preprocessing, compiling, linking
    • Preprocessor: #include, #define, #ifndef, etc.
  • Structure of C/C++ programs: header files, source files
    • Declarations vs definitions
    • Organization and use of header files, including #ifndef guards
    • Faking modularity in C – headers, implementations
    • Internal vs. external linkage; use of static for internal linkage
    • Dependencies and recompilation
    • Make and makefile basics
  • Version control basics (git)
    • add, commit, push, etc.
    • What to put in a repo and what to leave out

C Language

  • Data types
    • Casting
    • Pointers (pointer arithmetic, relationship to arrays)
    • String constants, arrays of characters, C string library
    • Structs
    • Extended integer types (e.g. int32_t, uint64_t)
    • typedef
  • Standard I/O library and streams
    • stdin, stdout, fopen, fread, scanf, printf, etc.
  • POSIX libraries - wrappers for systems calls
    • POSIX-layer I/O: open, read, write, etc.
    • Relationship between C standard library, POSIX library functions, and system calls
  • Error handling - error codes and errno
  • Process address space and memory map (code, static data, heap, stack)
    • Object lifetimes: static, automatic, dynamic
    • Dynamic allocation (malloc, free)
  • Function parameters
    • Call by value semantics (including structs, pointers)
    • Arrays as parameters - pointers
    • Using pointers for call-by-reference semantics
    • Function pointers as parameters
  • Linked data structures (e.g. linked lists, hash tables)
  • Potential bugs (e.g. memory leaks, dangling pointers)

C++ Language

  • Classes and modularity, namespaces
    • Create and change simple class definitions
    • Constructors, copy constructors, assignments, destructors
  • Other basic differences from C
    • Simpler, type-safe stream I/O (cout, cin, << and >>)
    • Type-safe memory management (new, delete, delete[])
    • References – particularly reference parameters
    • More pervasive use of const (const data and parameters, const member functions)

Midterm Practice

Below are links to some past midterms. We suggest using them to get an impression of the kinds of content that will be on the exam and using them as practice. However, note that the format and style of the questions will differ somewhat this quarter. Also note that some were given during a different amount of time, e.g. 70 min. In addition to old exams, you may want to review homework exercises, work the suggested exercises at the end of most of the lectures, and review lecture and section material.

Note: Past exams are generally correct, but they have not been vetted for accuracy so there is always the possibility of a typo or error in a sample solution somewhere. If in doubt, ask on Piazza.

Summer 2019
Exam   |   Sample Solution   |   Johnston (This Quarter!)
Spring 2019
Exam   |   Sample Solution   |   Hsia
Winter 2019
Exam   |   Sample Solution   |   Perkins
Autumn 2018
Exam   |   Sample Solution   |   Perkins
Summer 2018
Exam   |   Sample Solution   |   Perkins
Spring 2018
Exam   |   Sample Solution   |   Hsia
Autumn 2017
Exam   |   Sample Solution   |   Perkins
Summer 2017
Exam   |   Sample Solution   |   Perkins
Spring 2017
Exam   |   Sample Solution   |   Perkins
Summer 2016
Exam   |   Sample Solution   |   Perkins
Spring 2016
Exam   |   Sample Solution   |   Perkins
Winter 2016
Exam   |   Sample Solution   |   Perkins
Summer 2015
Exam   |   Sample Solution   |   Perkins
Spring 2015
Exam   |   Sample Solution   |   Perkins
Summer 2014
Exam   |   Sample Solution   |   Perkins
Spring 2014
Exam   |   Sample Solution   |   Perkins
Winter 2014
Exam   |   Sample Solution   |   Perkins
Summer 2013
Exam   |   Sample Solution   |   Perkins
Spring 2013
Exam   |   Sample Solution   |   Perkins
Summer 2012
Exam   |   Sample Solution   |   Perkins
Spring 2012
Exam   |   Sample Solution   |   Perkins
Spring 2011
Exam   |   Sample Solution   |   Perkins

Final Exam

Final Policies

Date: Friday, August 23, 2019 (in lecture)
Time: 10:50am - 11:50am (60 minutes)
Location: Sieg 134

You will be provided with:
  • Reference Sheet: We will provide a copy of the with your exam.
  • Printed Exam with Scratch Paper: Your exam will have extra blank paper for you to use if necessary. If you do use a blank page for a question, you must clearly make a note of that under the corresponding question. Otherwise, your work may not be graded.
  • Timekeeping (we will project a large clock at the front of the room)
You should bring:
  • Pencil/Pen
  • Eraser
  • Notes Sheet: You may bring up to TWO 8.5 x 11 inch sheets of paper, double-sided, with handwritten or printed notes. You are welcome to use your midterm notes sheet as one of the sheets of paper.
You are NOT allowed to use/wear during the exam:
  • Hats or Sunglasses
  • Cellphones, Calculators, or any other electronic device

Final Topics

The focus of every question on the final exam will be on material after the midterm. However, note that in the process of answering questions on the final you may need to use knowledge of C, C++, and POSIX from before the midterm.

More C++

  • Templates - template parameters for classes and functions, what happens when the compiler generates an instance of a template
  • STL, containers, and iterators. You are not expected to know picky details, but you should be able to use basic containers (vector, list, map) and iterators.
  • Smart pointers, reference counting semantics, using with STL. Understand differences between unique_ptr (cannot be copied, but can move ownership to another), shared_ptr (reference counting), weak_ptr (using to break cycles and why this is needed)
  • Subclasses, inheritance, virtual functions, dynamic vs static dispatch (function calls), vtables, constructors and destructors in subclasses
  • Pure virtual functions and abstract classes (what they are, how it works)
  • Using class heirarchies with STL and smart pointers, assignment slicing, value vs pointer semantics
  • C++ casts

Network Programming

  • Basic network layers: physical, data link, IP, TCP, application
  • Packets, and packet encapsulation across layers
  • IP addresses, address families (IPv4 and IPv6), DNS, ports
  • Stream sockets, file descriptors, read, write, close
  • Client steps: address resolution, create socket, connect socket to server, read/write (including retrys), close
  • Server steps: determine address and port, create socket, bind socket to address/port, listen (and how the OS queues pending connections), accept connection, read/write, close
  • Very basic HTTP and HTML (e.g., understand data sent and received by something like the HW4 web server)

Concurrency

  • Multiple processes and fork() (review of CSE351 mostly), shared file descriptors and close() in forked processes
  • Threads - concurrent execution inside a single process; know a few of the pthread basics (i.e., what it means to create a thread and start execution in a function; passing arguments to threads); basic issues involving sharing data between threads and locking.
  • Use of concurrency to improve throughput and resource utilization

Final Practice

Final exams given during Autumn, Winter, and Spring quarters are typically 110 minutes long. Exams given during Summer quarters are typically 60 minutes long (the same length as this quarter). The topics are generally the same so all of the old exams should be useful for review.

Note: Past exams are generally correct, but they have not been vetted for accuracy so there is always the possibility of a typo or error in a sample solution somewhere. If in doubt, ask on Piazza.

Summer 2019
Exam   |   Sample Solution   |   Johnston (This Quarter!)
Spring 2019
Exam   |   Sample Solution   |   Hsia
Winter 2019
Exam   |   Sample Solution   |   Perkins
Autumn 2018
Exam   |   Sample Solution   |   Perkins
Summer 2018
Exam   |   Sample Solution   |   Perkins
Spring 2018
Exam   |   Sample Solution   |   Hsia
Autumn 2017
Exam   |   Sample Solution   |   Perkins
Summer 2017
Exam   |   Sample Solution   |   Perkins
Spring 2017
Exam   |   Sample Solution   |   Perkins
Summer 2016
Exam   |   Sample Solution   |   Perkins
Spring 2016
Exam   |   Sample Solution   |   Perkins
Winter 2016
Exam   |   Sample Solution   |   Perkins
Summer 2015
Exam   |   Sample Solution   |   Perkins
Spring 2015
Exam   |   Sample Solution   |   Perkins
Summer 2014
Exam   |   Sample Solution   |   Perkins
Spring 2014
Exam   |   Sample Solution   |   Perkins
Winter 2014
Exam   |   Sample Solution   |   Perkins
Summer 2013
Exam   |   Sample Solution   |   Perkins
Spring 2013
Exam   |   Sample Solution   |   Perkins
Summer 2012
Exam   |   Sample Solution   |   Perkins
Spring 2012
Exam   |   Sample Solution   |   Perkins