MT2 Info
Overview and Proces
Time/Date: Thurs, Mar. 28th at 7 PM Pacific Pacific - 90 minutes (End at 8:30 p.m.).
- Location: (Based on Last Name)
- A-C: THH 301
- D-Ll (Lloyd): THH 201
- Lo-Q: THH 102
- R-Z: THH 101
- 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 each room or column closes to the wall as we need to be able to see your laptop screens for proctoring purposes.
- Do not angle your laptop screen toward the wall or use privacy screens. We must be able to see your screen reasonably well from the back of the room.
- Bring: A laptop or tablet with a minimum of 100 minutes battery run-time. Don’t count on outlet access.
- Format: we will likely pass out a paper version of the test with the question prompts. But you will enter your answers on Gradescope. Before the test begins, login into our Blackboard section, choose Assignmentments..Midterm 2 and click on the Gradescope link which will redirect you to Gradescope. You will then find a MT2 assignment (which will appear at the start of the exam) where you will be able to enter your answers to the questions. All answers need to be entered or uploaded to Gradescope, but you may use scratch paper to work out a problem. The majority of questions will be analysis, tracing, and conceptual. But 2 problems will involve coding.
- You may NOT use Codio for any of the tracing problems; ONLY the coding problems.
- For the coding problems, you MUST write your code in Codio. You MAY NOT use your own editor. Failure to follow this will result in a 0 on the exam. You can then compile and run it if you like, but we are not expecting you to do that and we will visually grade your code to assign points. Don’t waste time trying to compile/debug your code until you have finished the other problems. We will provide a blank Codio assignment with the skeleton files for you to work on. You can find a link to that assignment in Blackboard..Assignments..Midterm 1 after the exam begins. While it might be useful to compile, we don’t recommend running and debugging unless you have time.
- Questions: Any questions about the content of the exam (clarification, etc.) should be asked on EdStem (and not by raising your hand) to avoid disrupting your neighbors.
- Policies:
- You are allowed (1) 8.5x11 HANDWRITTEN (double-sided) cheatsheet with your USC email address and name written in the top-left corner of the cheatsheet on BOTH sides. What is printed on your cheatsheet MUST be handwritten (directly on the sheet or on a tablet and then printed) and MAY NOT contain prints of slides, copy/pasted code from homeworks/projects, etc. You can handwrite code from a past assignment, but just cannot copy/paste print. The reason is because by writing things, they will stick longer in your head and force you to recall what your code was doing, helping you learn.
- Other than the cheat sheet, the exam is Closed book, Closed notes, Closed Internet (search/reference). You may only access the following websites: Blackboard.com (to access the Gradescope or Codio links), Gradescope.com (to enter your non-coding answers), Codio.com (to perform the coding problems), and EdStem.com for asking questions. Other than that 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.
- Take care not to open the exam in 2 tabs / browsers or submit early. We can ONLY delete a submission if you click submit early and so you will need to start over again but will not be given additional time.
- If your laptop crashes, we will have a limited number of paper exams that you may use to finish the exam (but will not have the advantage of typing/editing code.)
- With 15 minutes remaining, no one will be allowed to leave the classroom (no bathroom use or leaving if you are finished). If you finish, simply close your laptop and sit quietly. Do NOT work on anything else.
- All answers and code must be submitted on Gradescope by 8:30 p.m. and anything after that will be consider a violation and may 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 3a
- Basic objects (structs)
- Assignment of objects
.
and->
operators- Use of
getline()
- Checking an input stream for failure
- Using C++
string
class
Unit 3b
- Defining your own classes
- public vs. private
- Constructors and Destructors and when they execute
- Defining member functions
- Splitting your class into files
Unit 4a
- Linked Lists
- Implementing basic operations (push, pop to front, middle, or back)
- Efficiency of various operations given variations of their implementation (with or without tail pointer, etc)
- Pros and cons compared to arrays
Unit 4b
vector<T>
anddeque<T>
basic operation- Efficiency of their operations
Unit 4c
- Doubly linked lists
deque<T>
class- Implementing basic operations
- Efficiency of various operations given variations of their implementation (with or without tail pointer, etc)
Unit 4d
- Multidimensional arrays
- Memory layout of a multidimensional arrays
- Passing multidimensional arrays to functions
Unit 4e
- syntax and use
- advantages of passing by reference
const
references
Unit 4f
- Checking for failure when opening a file
- Using C++
ifstream
andofstream
classes for File I/O - Checking for failure when attempting to receive input (extract a value from the stream)
Summary of Important Topics: All the topics from MT1 and prior assignments are also still requisite knowledge but the majority of the focus will be on the topics listed above. Be sure you are very comfortable with:
- Using structs and classes
- Writing code to perform operations on singly- or doubly-linked lists
vector<>
anddeque<>
- File stream objects and reading in data using the
>>
; operator - Using C++
string
s - Pointers (pass-by-reference, pointer arithmetic, pointers to pointers, etc.)
- C-strings and pointers to C-strings. Arrays of
char*
s (likeargv[]
) - Dynamic memory allocation (when it should be used and how to use it) and specifically how to allocate 1 and 2D arrays.
Practice Problems
Simple Tasks You Should Be Able To Do
File I/O and Arrays: Assume an input file with data values (strings or ints) separated by whitespace. Assume the first item in the list IS an integer of how many more items will appear. Read in all of the data items (after the first integer) and print them out in reverse order. Check to ensure each item was read successfully and quit if any item fails to be read correctly (e.g. if a string appears in the file of ints).
Sample MT2 (Gradescope and Codio)
-
On Blackboard..Assignments, you will find a
Sample MT2
folder with links to a Gradescope MT2 exam with conceptual/tracing questions and a Codio link to some sample coding problems. Solutions are also linked on Blackboard and below:
Spring 2023 MT2
Previous and Related Programming Exams
Here are some practice materials. Note that the topics they cover might be slightly different from our list of topics.
-
Spring 2015 Exam and cost.cpp solution and scale.cpp solution.
-
MT2 Prep exercises on EdStem Lessons which are old exams created by a former faculty of USC and Princeton. This material is from Princeton University, which has a similar programming exam but gave 2 problems for the whole period and did so in Java. Naturally, you should practice them in C++ and not Java.
- Foodlympics
- Part 1 Solutions
- Part 2 Solutions
- Practice Exam 2: Snow. The test files are available here.
-
The C++ versions of the prototypes should be:
double meltage(double currSnow, int temp, int salt); void printArray(double arr[], double length);
- You should use
cin.fail()
to detect the end of input (i.e. when it fails, assume the input is over.) - For part 2, you can assume there are at most 100 scenarios.
- Use
#include<iomanip>
andcout << setw(8) << setprecision(3) << x
to print the doublex
in the right format.
-
- Practice Exam 3: Hats. The test files are available here.
-
The C++ versions of the prototypes should be:
bool isD(int r[], int length); int maxCycleLength(int arr[], int N);
- You can assume the permutation length is at most 100.
- You should use
cin.fail()
to detect the end of input.
-
-
Practice Exam 4: Birthdays. No test files are available.
-
Practice Exam 5: Restaurants. No test files are available.
Short Practice Problems
In case you want some practice that takes less than 90 minutes, here are 5 smaller exercises (use “Select an Exercise”) of varying difficulty. They may be less relevant to topics on the midterm 2, but can serve as additional practice if desired.
Straightforward:
Medium to Challenging: