Computer Science at IUS

Fall 2003 C-202

Test Review #3

Student Name:

 
 

1 - How can one allocate a node dynamically to a pointer P?

 

 

 

2 - How one can access the member Item of a node pointed to by P?

 

 

 

 

3 - What is the value of the member Next in the last node of the linked list?

 

 

 

 

4 - Given the definitions

struct Node

{

                int Data;

                ptrype Next;

};

typedef Node* ptrType;

 

ptrType P =  new Node;

Which among the following is the correct way to assign the value 7 to the Data field, for the node dynamically allocated by the last line above.

 

a)       P.Data = 7;

b)       P->Data =7;

c)       P->Next = 7;

d)       P.Next = 7;

 

5 – Given the declaration of some variables :

                int *P, Q;

 

Which statement is correct?

 

a)       P is a pointer variable.

b)       Q is a pointer variable.

c)       Q is variable of type int.

d)       Both (a) and (c).

e)       Both (a) and (b).

 

6- Given the declarations

 

int X;

int *Z  = new int;

 

a)       All memory is allocated statically.

b)       All memory is allocated dynamically.

c)       X and Z are statically allocated, and Z points to dynamically allocated store.

d)       None of the above.

7 - In a linked list, an item is inserted by finding its place in the list and:

 

a)       Resetting all the pointers to the right.

b)       Resetting at most two pointers.

c)       Resetting all the pointers at the beginning of the list.

d)       None of the above.

 

8 – To delete an item in a linked list, find its place and:

 

a)       Reset all the pointers to the right of them.

b)       Reset all the pointers to the left of them.

c)       Reset a pointer to bypass the item.

 

9 - Given the declarations

 

typedef  float *ptrType;

ptrType P;

 

Which of the following are correct?

a)       P = 3.5;

b)       *P = 3.5;

c)       cout << P;

d)       cout << *P << endl;

 

10 – A pointer variable has been declared as follows:

 

int *Count;

 

Which of the following are true?

a)       Count is always automatically initialized to the pointer NULL that doesn’t point to anything.

b)       Count is automatically initialized: Count = 0;

c)       Count is automatically initialized: *Count = 0;

d)       All of the above are true.

e)       None of the above are true.

 

11 - Given the declaration

float* P;

We say that P is a float Pointer, or is a pointer to float type of variable, because:

a) P is a variable of type float.

b) The content of P is a number of type float.

c) The content of P is an address of a location that holds a float.

d) P can reference a location in memory that holds a float.

 

 

12 - Given the declarations

int *  x;

int *  y = new int;

a) Only x is not initialized.

b) x is uninitialized; variable y is initialized to point to a free store and that store is not initialized.

c) All memory allocated above is initialized. Variable y is initialized to point to memory on the free store and that is initialized to 0.

e)       No memory is initialized.