Final Info
Overview and Proces
MUST BE TAKEN IN PERSON / NO REMOTE EXAMS
- Date/Time: Sat, Dec. 9 at 11 a.m. Pacific
- Duration: 80-90 minutes (1 hour, 20-30 minutes)
- Location based on Last Name Starting Initial:
- 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. 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 90 minutes battery run-time. Don’t count on outlet access.
- Format: The majority of the final will be tracing, analysis, and “fill-in-the-blank coding”.
- A paper copy of the exam will be given. We are still deciding if you will only answer on paper OR key in your answers to Gradescope. If we have you key in your answers to Gradescope, then you can login to Blackboard and choose Assignments..Final folder. Then click on the Gradescope link which will redirect you and you can find the “Final” assignment.
- 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:
- No cheatsheet will be allowed. Any reference material that is not pertinent to the problem will be provided.
- The exam is Closed book, Closed notes, Closed Internet (search/reference/chatGPT or other AI-tool). You may only access the following websites: Gradescope.com, Codio.com, and Piazza.com for asking questions. Other than that your mind and scratch paper are the only resources allowed. 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.
- 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.
- If using Gradescope, take care not to open the exam in 2 tabs / browsers or submit early.
- If your laptop crashes, we will likely just accept the paper version.
- 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. If you finish earlier, you may leave but need to sign out before you leave the room.
- All answers and code must be submitted on Gradescope by 12:20 or 12:30 p.m. (not Codio) and anything after will be considered a violation and will result in SEVERE penalties!
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
Ways to Prepare
- Study the slides
- Review labs.
- Redo the in-class exercises by clicking the “Reset To Scaffold” button. Focus on the array tasks and function tasks.
- Redo your HW/Lab exercises (especially the tracing exercises)
- 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: