MT1 Info
Overview and Proces
MUST BE TAKEN IN PERSON / NO REMOTE EXAMS
- Time/Date: Thurs, Feb. 27nd at 7 PM Pacific Pacific - 90 minutes (End at 8:30 p.m.).
- Location: (Based on Last Name)
- A-Le: THH 101
- Li-Z: THH 201
- OSAS Accommodations: If you have USC approved accommodations, you will need to coordinate in advance with the OSAS office to schedule your exam at the testing center.
- Do not sit in the back row of the classroom.
- Bring: A pencil and good erase.
- Format: The problem will mainly be fill in the blank and multiple choice but related to tracing and coding (e.g. choose which code choices should should be filled into a blank)
- Questions: Raise your hand, but PLEASE try not ask excessive questions (and if you know that you tend to ask questions, sit on the aisle or up front.)
- Policies:
- The exam is Closed book, Closed notes, Closed Internet (search/reference). Your mind and scratch paper are the only resources allowed. No calculators, phones, or textbooks are allowed.
- You must request to use the restroom or leave the classroom for any reason and only 1 person will be allowed to leave at a time.
- You may NOT have headphones or earbuds in.
- With 10 minutes remaining, no one will be allowed to leave the classroom (no bathroom use or leaving if you are finished). If you finish, simply sit quietly. Do NOT work on anything else.
- All writing must cease by 8:30 p.m. and anything after that will be consider a violation and WILL result in penalties!
Topics
The following is the list of topics that you should be familiar with. Use it as a guide to help your studying.
Unit 1a
- data types (int, char, double, bool)
- variables, scope
- experssions (including integer division, modulo, etc.)
- casting
- basic input/output with
cin
andcout
- basic math functions
pow
,sqrt
,sin
,cos
,abs
, etc. rand()
andsrand()
functions andRAND_MAX
constant
Unit 1b
- comparison operations
if
,else
,else if
statements- Not covered: switch (case) statement, ternary
? :
operator
- Not covered: switch (case) statement, ternary
while
anddo..while
loopsfor
loopsbreak
andcontinue
statements
Unit 1c
- defining arrays
- using arrays as look-up tables
- character arrays / C-strings
- Basic function calls, prototypes, etc.
- scope
- pass-by-value
- functions with array arguments (pass-by-reference)
- return types and
void
functions - need for prototypes
- C strings (null-terminated character arrays)
- Built-in functions:
strlen
,strcpy
,strncpy
,strcmp
Unit 1d
- big-O notation and using it to perform simple classification of code runtime
Unit 1e
- Compilation using
g++
, its options/flags and how to compile code with multiple files - Understanding of the need for prototypes and the use of header (
.h
) files
Unit 2a
- declaring pointer variables (
int *
) - referencing (
&
) and dereferencing (*
)
Unit 2b
const
arguments- pointer arithmetic
- Array names and pointer equivalency
- Array access and pointer arithmetic/dereference (e.g.
ptr[i] <=> *(ptr+i)
)
Unit 2c
- Concept of dynamic memory allocation and when to use it
- Syntax of using
new
anddelete
both with scalars (individual variables) and arrays
Unit 2d
NULL
andnullptr
- Handling of
char
vs.char*
types const char*
as the type of string literals
Unit 2e
- pointers to pointers
- arrays of pointers (like char* argv[])
- command line arguments (
argc
andargv[]
)
Unit 2f
- Shallow vs. deep copy
- 2D array allocation via many 1D allocations
Lab Material
- Basic compilation and debugging
- Understanding memory errors
Homework and Project Material
- Concepts and understanding of topics and implementations from your homework and projects.
Practice
Here are some practice exams. Note that the topics they cover might be slightly different from our list of topics (below).
- Practice Midterm given in Lab the week before the exam.
- Spring 2023 MT1 and Solutions
- Ignore questions about multi-dimensional (2D- and 3D-) arrays
- EdStem Exercises and Slide Exercises:
- EdStem..Dynamic Memory:
Example: OneOrMany
- EdStem..Pointers-to-Pointers:
cmdargs_ptr_ex
andcmdargs_ptr_ex2
- Unit 2a Slides: Pass-by-reference exercises at the end of the slide deck.
- We strongly recommend trying the algorithmic thinking exercises in the EdStem Lesson: Array Tasks.
- EdStem..Dynamic Memory:
- Midterm Review Packet from Fall 2016-2018 [NO SOLUTIONS - Either run the code, crowdsource answers with fellow students, or come to office hours.]
- There are some duplicate questions that you can ignore.
- Q7 solution explanation
- CS 103 Sp15 Midterm and Solutions
- This was a 60 minute exam
- Ignore the questions related to the
draw
library.
- CS 103 Fa14 Midterm and Solutions
- This was a 90 minute exam
- Additional midterm review questions with no solutions.
- Video explanation of Q4 of Gradescope Sample MT1