Final Info
Overview and Proces
MUST BE TAKEN IN PERSON / NO REMOTE EXAMS
- Date/Time: Sat, Dec. 12 at 11 a.m. Pacific
- Duration: 75 minutes (1 hour, 15 minutes)
- Location: THH 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 and finish by 1 p.m.
- 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 some “fill-in-the-blank” coding. There will be 1 question requiring you to code a problem from scratch.
- 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.
Lec 1
- Data Types
Lec 2
- Algorithms
- Constants
Lec 3-4
- Expressions (understand various operations and operators such as
%and/) - Output with
cout - Input with
cin - Variables and assignment
- Statements
- Libraries (eg. Math function calls)
- I/O manipulators:
setprecision, andfixed
Lec 5
- Division and Modulo operators
- Assignment operations (shift and rotations)
Lec 6-7
- Conditional statements
- Comparison operators
if,if..else, andif..else if...elsestatements- Logical operators (
&&,||, and!)
Lec 8-11
whileloopsforloops- Tracing of loops
- Writing basic
whileandforloops.
Lec 12-13
- Arrays
Lec 14-15
- Strings
Lec 15-18
- Nested Loops
- Multidimensional outputs
- Array problems involving nested loops
- Use of sequential or nested loops (when each is needed)
- Computational/Algorithmic thinking and code development
breakbehavior in a nested loop
Lec 19-24
- What is a prototype / signature of a function.
- Return value, input arguments, etc.
- 3 steps of writing and using fuctions: declaration, definition, calling
- Appropriate call syntx
- Formal vs. Actual arguments
- Pass-by-value (for single variables)
- Pass-by-Reference (for arrays) and the appropriate syntax for passing arrays.
Lec 25
- Basic operation of bubble and selection sort
- Understanding linear vs. quadratic algorithms
- Basic compilation
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.
- Redo MT2 Preparation (on Codio)
- Sample Fall 2020 Final on Gradescope
- Sample Spring 2021 Final on Gradescope
- Sample Fall 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/2and the preceding character wherenis 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,
valsthat was declared to be of size,maxSize, but that currently is only using the firstcurrSizeelements. Insert thenvalues: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 addingnelements 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-1because 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:
