CODEMASTERS YOSEMITE PROGRAMMING TEST
C/C++
1)
Write a class that implements a simple list. It must provide methods to add and remove values, and provide some way to iterate through all elements in the list.
2)
Write destructors for these two classes.
class A
{
public:
int *a;
A() { a = new int[10]; }
};
class B : public A
{
public:
int *b;
B() { b = new int[20]; }
};
3)
Given the following definition, write a constructor that sets the value of m_constant.
class CConstant {
public:
const int m_constant;
const int Get() {return m_constant; }
};
4)
Write a copy constructor for the Circle class defined below. In what two situations does the C++ compiler use the copy constructor implicitly?
class Circle {
public:
Circle();
int center_x;
inst center_y;
double r;
};
5)
What is a hash table? What is its purpose, and how does it function?
6)
What does mysteryFunction return?
int mysteryFunction ( int n)
{
int k = 0;
while( n ) {
k++; n = n / 10;
}
return k;
}
Assembly
1)
What does MysteryFunctionAsm() do. What assumptions does it make?
void MysteryFunctionAsm(unsigned char far *addr,
unsigned value1,
int value2)
{
_asm {
les di,addr
mov al,BYTE PTR value2
mov ah,al
mov cx,value1
shr cx,1
rep stosw
}
}
2)
Write a function in assembly language (80x86, 680x0, or PowerPC) that returns the address of the first byte in a memory block that has the most significant bit set. The function will take a pointer to the beginning of a block of RAM, and the size of the memory block. The function must return the address of the first byte, or null if a non-zero byte is not found. The function should be as fast as possible, especially for long searches.
The prototype for the function is:
void* FindNegByte(void *ram, char size, char key_value);
3D
1) Matrix Math
Calculate the sum of these two matrices.
|2 3| |3 -1|
|1 4| + |5 6|
2)
Calculate the product of these two matrices.
|2 3| |5 6|
|1 2| * |3 0|
3)
What does mysteryFunction3D() compute?
struct vector_3d_typ {
// a 3-D vector along with normalization factor
float x,y,z,w;
} vector_3d,*vector_3d_ptr;
float mysteryFunction3D_1(vector_3d_ptr u,vector_3d_ptr v)
{
return( (u->x * v->x) + (u->y * v->y) + (u->z * v->z));
}
4)
What is the identity matrix of a 3 x 3 matrix?
5)
Write a function to multiply two 16.16 fixed point numbers. Where...
typedef long FIXED;
6)
What is a BSP tree? How does it function?
Internet
1)
Write a function to load into memory the html page at
http://www.yahoo.com.
2)
Re-write the simple list class for the first class so that it is threadsafe.
Do anyone like to try this?