In the following search function for a linked list (using the Node and NodePtr as defined in the text), why is there code to check if here is NULL?

NodePtr search(NodePtr head, int target)
{
nodePtr here = head;
if(here == NULL)
{
return NULL;
}
else
{
while( here->data != target && here->link != NULL)
{
here = here->link;
}
if(here->data == target)
{
return here;
}
else
{
return NULL;
}
}
}
a. the list may be empty
b. the list may be full
c. there is no reason for that code to be there
d. A and B


a. the list may be empty

Computer Science & Information Technology

You might also like to view...

Which of the following icons represents the "Turn off the display" option?

A.
B.
C.
D.

Computer Science & Information Technology

Two methods that are expected to be in all Java classes are:

(a) getName and setName (b) toString and equals (c) compareTo and charAt (d) toLowerCase and toUpperCase

Computer Science & Information Technology

The process of normalization holds each table to a progressive series of criteria known as ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

All walls should have a 1-hour minimum fire rating

Indicate whether the statement is true or false.

Computer Science & Information Technology