CS1003 Final Exam: Review[Summer 2003 Exam] [Summer 2003 Exam Solutions/Notes] The Final Exam will consist of roughly six questions, each with a few subsections. Overall, concentrate on the
- Statements versus Expressions: Statements change the state
of the machine (through side-effect; ie manipulate memory,
print, etc). Expressions have a value. Some statements, such as
i++;also have a value. Questions might include finding redundant or unnecessary code. You may also be given C code written in a slightly non-standard way and asked for results given a set of inputs (trace through the code).
- Code Execution: You should be able to trace through the state of the machine given a section of C code. This can be very informal, but you should be able to identify the value of a variable at various points in a program.
- You should understand at a basic level what happens to the machine when a function is called. This includes call-by-value. Given a program with multiple functions, you might be asked the result of a variable after execution. Using pointers can change whether changes made to a variable in a function are visible from outside the function. Refer to the swap.c examples. You should be familiar with the "stack" execution method where each function call puts a new "frame" of values on the top of the stack. When the function terminates, the frame is destroyed.
- Pointers: Again in the same category as above, but do know the difference between a pointer variable and a normal variable. Don't worry about pointer to pointer (**) questions (but do be familiar with string arrays). Knowing the swap.c example should be enough.
- calloc, malloc, free: You should know at a high level what
these functions do, but you won't be asked to use them. They
will probably appear in a program so you want to know why they
are different from declaring a variable. These allocate you
memory on the heap. Also, the sizeof() operator will show up, but you
won't be asked to directly use it.
freedeallocates memory (frees memory allocated on the heap).
- Structs: If you can understand the simple struct examples, the addressbook, and the linked list you will be all set. Don't worry too much about the syntax, but know what the struct and typedef statements do: struct declares a new data type whereas typedef is way of renaming types. You might be asked to create a struct, but I would not ask for exact syntax. structs behave just like variables when being passed to functions.
- Arrays: Know how to type and declare arrays. Remember that array names are the same as a pointer to the first element in the array whereas arrayname is the first element in the array. Arrays can not be declared in a function and returned like normal variables -- they are always passed around using a pointer. This means you can't create an array in a function and return it (unless you use calloc... the memory is safely reserved for the array on the heap rather than on the stack).
- Data types: No need to memorize data types, but do know which keywords can hold floating point numbers and which hold integers. Know how "if" interprets true/false values.
- Logic: You might be asked to solve a problem by writing pseudocode.
- Debugging: You won't need to fix syntax errors, but you should be able to read C code that claims to solve a problem and identify errors in the flow of reasoning.
- Recursion: Be able to explain what happens to the machine during recursion as well as write pseudocode recursive programs.
- Running time analysis: Be able to figure out roughly how many operations a section of code takes given an input size (usually n). Your analysis need not be rigorous.
- Sorting/Searching: You will not be asked to reproduce sorting or searching code on the exam, but you should know the strategy and running times of those we saw in class.
- Files: you should be familair with scanf/printf and some of the very basic formatting options. However, you won't be asked to use or debug these or any other file input/output functions.
- Standard Library Functions: If I use any, I'll define their inputs and outputs in the question.
- Header Files: You might be asked something about good program design (ie put your interface or public data in the .h file and keep the implementation in the .c file). This would most likely come up when defining a new struct and writing some functions to manipulate it.
- Understand how mergesort works