The exam will be on
Thursday, 14 April 2005,
9:30 - 10:45 am.
Quizzes:
Study quiz 4 for some of the topics to be covered
on the exam, but these topics will also be mentioned below.
Recitations:
You should study Recitations 7 through 11, but links to these will be given below.
Topics:
Nothing directly from the Weiss book that is not also discussed
below. (But the Weiss book might help your understanding.)
Strings:
-
String Examples
Creating strings, accessing and printing chars from them
-
String Basics (less emphasis on this material)
-
String Functions
Examples of functions that work with strings
Arrays of Strings:
-
Print Array of Strings
- Rec 7:
Array of Strings : command line arguments (skip self-reproducing programs)
-
Array of Strings as Parameter (less emphasis)
2-dimensional arrays:
-
2d-arrays
- Rec 8:
Pascal's Triangle : 2-dimensional arrays
structs:
-
Structs Overview
-
Simple "bare" structs seldom used
- Rec 9:
Structs and RPN Using bare structs, and an array of structs
-
Java vs. C Using pointers (or references) to structs
-
Structs as parameters Examples of both "bare"
structs and pointers to structs
Use of structs:
-
Linked List Stack Use of self-referential structs
- Rec 10:
Linked list queue
Files:
-
File Input/Output
- Rec 11:
Merging Files
Possible Questions:
- Questions about the way ordinary 2-dimensional arrays in C are
laid out in memory. For example, suppose an array is declared
int a[6][5];.
- Give the formula for accessing the array element
int a[i][j]; in simulated linear storage.
- The array reference
int a[4][7]; is technically illegal. Why is it
illegal? This reference will access a well-defined location in the
array because of the way C handles 2-dimensional arrays.
How will C try to access the location and which location will
it be (using array subscripts that are in range)?
- Questions about "bare" structs:
- A "bare" struct is one not defined as a pointer to the object
(no stars in the main declaration). Why do we recommend against the use
of bare structs?
- Does Java support bare structs?
- What happens when you return a "bare" struct from a function
or have two "bare" structs on either side of an assignment statement?
- Questions about structs:
- Given a struct "tag" declaration (such as that in the program at the
start of item 13), how does one do the following.
(I might give specific examples to work with in a case like this.)
- Allocate a pointer to such a struct (declaration
of a local variable on the stack).
- Allocate a single (bare) copy of such a struct (declaration
of a local variable on the stack).
- Set the pointer in i) pointing to the struct in ii) above.
- Allocate an array of (bare) copies of such a struct (declaration of
an object on the stack).
- Allocate such a struct using malloc, returning a pointer to it.
- Allocate an array of pointers to such a struct using malloc,
and then use malloc to allocate each individual struct.
- Initialize an array of such structs using {} notation.
- Questions about RPN:
- Given an example of an RPN string with numbers for
operands, show how to use a stack to evaluate it.
- Show how to use the "railroad" diagrams to translate
an example arithmetic expression (of the type in class) into RPN.
- Questions about linked lists:
- What sort of struct is needed for a linked list?
Assume you are give such a struct and a pointer to a linked list made up
from the struct.
- Give code to chase down a linked list, visiting the nodes as you go.
- Give recursive code to chase a linked list in reverse, visiting the nodes as you go.
- Give code to splice two linked lists together, the second tacked on at the
end of the first.
- Suppose a pointer p points to a node in a linked list.
Give code to delete the next node in line after the given node
(unless this is the last node). Why couldn't you in general delete the
node that was pointed to?
- Questions about queues:
- Draw a diagram of a queue, showing the front and rear
pointers, and the direction of the queue as a linked list.
- A queue has the form that is has so that one can insert a new
node at the (front or rear?) and delete the node at the (front or rear?)
in constant time (time independent of the length of the queue).
- There is one other insert or delete operation that one can do with
a queue in constant time. What is it?
- Question about file input/output:
- Given code to copy a file from one location to another, as in the first
program under item 16 above, rewrite the code so that the actual copying is
inside a function.
- Questions about merging two files:
- If you are merging two files without sentinels, say what you do if
you come to EOF on the first file and not on the second.
- If you are merging two files without sentinels, give the circumstances
under which you could come to EOF on both files at the same time.
Say what you would do in this case.
Copyright © 2011, Neal R. Wagner. Permission is granted
to access, download, share, and distribute, as long as this notice remains.