Which of the following would completely remove all the nodes in a linked list and return them to the freestore?

void free(NodePtr head)
{
//what goes here?
}
a.
if(head == NULL)
return;
else
{
free(head->link);
delete head;
}
b.
NodePtr here, prev;
while(head->link != NULL)
{
here=head;
prev= head;
while(here->link != NULL)
{
prev=here;
here=here->link;
}
delete here;
prev->link=NULL;
}
delete head;
c.
NodePtr here, prev;
while(head != NULL)
{
here=head;
while(here->link != NULL)
{
prev=here;
here=here->link;
}
delete here;
prev->link=NULL;
}
delete head;
d.
NodePtr here, prev;
while(head->link != NULL)
{
here=head;
prev= head;
while(here->link != NULL)
{
prev=here;
here=here->link;
}
delete here;
prev->link=NULL;
}
delete head;
e. all of the above
f. A and B
g. B and C

f. A and B

Computer Science & Information Technology

You might also like to view...

The operations of the ADT sorted list are based upon the ______ of data items.

a) names b) values c) sizes d) positions

Computer Science & Information Technology

Which of the following file systems supports file and folder permissions?

A. DOS B. FAT16 C. FAT32 D. NTFS

Computer Science & Information Technology