CSI1102
Quiz 4
Q1. [3 marks]
Determine the validity of the following statements.
(T/F) 1. Traversing a maze is
much easier to do iteratively than recursively.
(T/F) 2. Queues
and Stacks can be implemented using either arrays or linked lists.
(T/F) 3. If an exception is thrown and is not
caught anywhere in the program, then the
program terminates.
Q2. [3 marks]
Example: gcd(18,4) = gcd(4,2) = gcd(2,0) = 2
static int gcd(int a, int b)
{
if (b == 0)
return a;
else
return gcd(b, a%b);
}
Last Name: |
|
First Name: |
|
Student number: |
|
Section: |
|