Final Info
Overview and Proces
MUST BE TAKEN IN PERSON / NO REMOTE EXAMS
- Date/Time: Sat, Dec. 14 at 11 a.m. Pacific
- Duration: 70 minutes (1 hour, 10 minutes)
- Location based on Last Name Starting Initial:
- A-O: SGM 123
- P-Z: SGM 101
- ALL students with accommodations: Students with OSAS-approved accommodations MUST schedule the exam on the same date (earlier in the day is fine) with the OSAS testing center.
- Format: The test will be taken on paper. You should use a pencil so you can erase, but MUST write DARKLY as we will scan your exams afterwards for grading purposes. The majority of questions will be multiple choice based on code analysis/tracing and conceptual material as well as “fill-in-the-blank” to complete code.
- Policies:
- Raise your hand if you have questions and we will come to you.
- We will provide scratch paper for you to write on, BUT NO WORK ON SCRATCH PAPER WILL BE GRADED. You must fill in the appropriate boxes on the actual exam. Scratch paper will be collected and shredded after the exam.
- The exam is Closed book, Closed notes, no phones or electronic device usage). Any violation of these rules will result in a report to the Office of Academic Integrity with a proposed sanction of F in the class.
- Please use the restroom ahead of time so as to avoid interrupting other students. If needed, 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.
- If you finish the exam early, submit it to us and then you MAY leave.
Topics
The following is the list of topics that you should be familiar with. Use it as a guide to help your studying. While the final is cumulative, it will focus on strings, nested loops, arrays, and functions! Focus on those topics first.
Unit 0b
- Data Types
- Constants
Unit 0c
- Algorithms
- Syntax vs. Semantics
Unit 1a
- Expressions (understand various operations and operators such as
%
and/
) - Output with
cout
- Input with
cin
Unit 1b
- Variables and assignment
- Statements
- Libraries (eg. Math function calls)
- I/O manipulators:
setprecision
, andfixed
Unit 1c
- Division and Modulo operators
- Assignment operations (shift and rotations)
Unit 1d Conditional Statements
- Conditional statements
- Comparison operators
if
,if..else
, andif..else if...else
statements- Logical operators (
&&
,||
, and!
)
Unit 2a and 2b Loops
while
loopsfor
loops- Tracing of loops
- Loop coding
break
statement
Unit 2c Arrays
- Declaring and sizing
- Accessing elements (with an index)
- Loops and arrays
- Initialization with constants
Unit 2d Strings
- C-Strings (character arrays) vs. C++
string
s differences and similarities - Issue with
cin
and C-strings - What C-Strings cannot do
string
array access, size, comparison, and substrings
Unit 3a Nested Loops
- Tracing and behaviour
break
behavior in a nested loop
Unit 3b and 3d Array Tasks
- Use of sequential or nested loops (when each is needed)
- Computational/Algorithmic thinking and code development
Unit 3d Debugging
- Debugging techniques
Unit 4a Call Functions
- What is a prototype / signature of a function.
- Return value, input arguments, etc.
Unit 4b Defining Functions
- 3 steps of writing and using fuctions: declaration, definition, calling
- Appropriate call syntx
- Formal vs. Actual arguments
Unit 4c Passing Arguments
- Pass-by-value (for single variables)
- Pass-by-Reference (for arrays) and the appropriate syntax for passing arrays.
Unit 4d Compilation and Debugging
- How to compile a program at the command line using
g++
. - Debugging strategies
Unit 4e Sorting
- Basic operation of bubble and selection sort
- Understanding linear vs. quadratic algorithms
Ways to Prepare
- Study the slides focusing on tracing questions.
- Redo Lab exercises
- Review HW coding exercises and ensure you fully understand how to approach those problems.
- Redo the in-class exercises by clicking the “Reset To Scaffold” button. Focus on the array tasks and function tasks.
- Sample Fall 2020 Final on Gradescope
- Sample Spring 2021 Final on Gradescope
- Go through the review problems at the end of each relevant chapter in the textbook. Some selected problems from the 2nd edition:
- Ch. 5
- P5.6-5.7
- P5.10 (rather than choosing a random, internal pair to flip, exchange the character at index
n/2
and the preceding character wheren
is the length of the string, andn >= 4
). Do nothing (return) the string if its length is less than 4. - P5.12
- P5.25 (implement a function
int zipFromBarCode(string bar)
that returns the zip code or -1 if there is an error)
- Ch. 6
- P6.17,
- P6.21-23
- P6.31
- Ch. 5
- Other practice problems
- Implement the function:
int insertRun(int vals[], int currSize, int maxSize, int start, int num, int n);
- This function takes an array of integers,
vals
that was declared to be of size,maxSize
, but that currently is only using the firstcurrSize
elements. Insert then
values:num
,num+1
,num+2
, … at the indexstart
, moving the original elements occupying those locations to the right. Return the new number of occupied/used elements in the array. If addingn
elements would cause the array to grow beyondmaxSize
, do nothing and return-1
.- So given an array:
int vals[20] = {99,98,97,96}
; - A call to
insertRun(vals, 4, 20, 2, 10, 5)
would update the array contents to:{99,98,10,11,12,13,14,97,96}
and return9
- A call to
insertRun(vals, 4, 20, 2, 10, 17)
would update the array contents to:{99,98,10,11,12,13,14,97,96}
and return-1
because adding 17 elements to the 4 that already exist would go beyond the 20 locations.
- So given an array:
- This function takes an array of integers,
- Implement the function: