/* 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_TIME);
task main()
cfw_
SetSensor(SENSOR_1, SENSOR_TO
/* 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 forward for length time
repeat(length)
cfw_
until(sem = 0
/* 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_TIME);
task main()
cfw_
SetSensor(SENSOR_1, SENSOR_TO
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 > 1 is prime positive integers r and s, if n = r s the
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 the
truth of an assertion
Statement Form: an expressio
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:
x(P (x) q(x) xP (x) xQ(x)
Example 3:
x(P (x) Q(x) xP (x
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:
To more than two sets: A1 A2 A3 . . . An
To two ident
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.
Such an object is called an element of the set
Notation:
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 of M/C, T/F, Matching, and/or short answers).
Pseudo co
/* Solution to question 1 of NQC Practice */
task main()
cfw_
SetSensor(SENSOR_1, SENSOR_TOUCH);
SetSensor(SENSOR_3, SENSOR_TOUCH);
start check_touch1;
start check_touch3;
start go;
/* The Untitled block. This must be in a separate
* task so that it can
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 to the
functio). Local x is changed to 300. When the fu
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 (Events, Tasks, Communication): 20%
General Knowledge
Th