Friday, July 31, 2009

This is a question about data structures (linked lists)?

Suppose that p is a pointer variable that contains the NULL pointer. What happens if your program tries to read or write *p?


A. A syntax error always occurs at compilation time.


B. A run-time error always occurs when *p is evaluated.


C. A run-time error always occurs when the program finishes.


D. The results are unpredictable.





Suppose that f is a function with a prototype like this:


void f(________ head_ptr);


// Precondition: head_ptr is a head pointer for a linked list.


// Postcondition: The function f has done some computation with


// the linked list, but the list itself is unchanged.





What is the best data type for head_ptr in this function?


A. node


B. const node


C. node*


D. const node*

This is a question about data structures (linked lists)?
for 1st Q.... the answer is ... it is run time error it will occur when u try to read data into the NULL pointer


for 2nd Q... node*


No comments:

Post a Comment