COMP106 Spring 2005 Final exam study guide
The final exam will be divided into 4 sections:
General knowledge: 25%
Algorithm / Pseudo-code: 30%
NQC Basics (including top-down design): 25%
Advance NQC (
/* Solution to question 3b of NQC Practice */
#define SPIN_TIME 104 / the time to spin 90 degrees
/ move in a square
void square (int length)
cfw_
repeat(4)
cfw_
Forward(length);
Spin_left(SPIN_TI
/* Solution to question 3c of NQC Practice */
#define SPIN_TIME 104 / the time to spin 90 degrees
int sem; / the semaphore
/ move in a square
void square (int length)
cfw_
repeat(4)
cfw_
/ go forwa
/* Solution to question 3a of NQC Practice */
#define SPIN_TIME 104 / the time to spin 90 degrees
/ move in a square
void square (int length)
cfw_
repeat(4)
cfw_
Forward(length);
Spin_left(SPIN_TI
In mathematics:
Denitions are often biconditional, e.g.,
An even integer is one that equals twice some integer.
n is even an integer k such than n = 2k
n is odd an integer k such than n = 2k + 1
n
Statement: a declarative sentence that is either true or false, but
not both
E.g., The sum of x and y is greater than 0 is NOT a statement
Argument: a sequence of statements aimed at demonstrating
More examples of logical equivalences:
Example 1: It is easy to see that:
x(P (x) q(x) x P (x) x Q(x)
but these are not equivalent; for example let P (x) be 2x + 1 = 5
and Q(x) be x2 = 9.
Example 2:
Cartesian Products:
For sets A and B, the Cartesian product or cross product of A
and B is denoted by
A B = cfw_(a, b) | a A, b B
(a, b) is an ordered pair (therefore, A B = B A !)
Generalizations:
Set: A term that is used as undened, basic in Set Theory
Some important properties:
A well-dened collection of objects:
For any object, we are able to determine whether or not it is
in the set.
Su
COMP106 Practice Midterm
Page 1 of 2
Note: Make sure you try the questions before looking at the answers!
The midterm will be equally divided into the following sections:
General Knowledge (a mixture
1. The robot goes backward for 3 seconds, then forward for 1 second.
The main task passes the value 100 to foo, which gets stored in foo's
parameter x (remember a parameter is a local variable, local
import
import
import
import
java.awt.*;
java.awt.event.*;
javax.swing.*;
javax.swing.event.*;
public class EventTest extends JFrame
cfw_
int count = 0;
JTextField countDisplay = new JTextField("0");
t