What is wrong with the following definition of headInsert?

struct Node
{
int item;
Node* link;
};

typedef Node* NodePtr;

void headInsert(NodePtr& head, int data)
{
NodePtr tmp = new Node;
tmp->item = data;
head->next = tmp;
tmp->next = head->next;
}
NodePtr head;
headInsert(head, 4);
a. head->next is pointing to NULL
b. if there were any nodes following head they are now lost.
c. nothing is wrong.
d. tmp should be declared to be a Node not a NodePtr


b. if there were any nodes following head they are now lost.

Computer Science & Information Technology

You might also like to view...

The quickest way to move a sheet is to copy and paste them in the new location.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Which of the following are the two types of generic hubs used for connecting USB devices?

a. Battery-powered b. Bus-powered c. Solar-powered d. Self-powered

Computer Science & Information Technology

A site bridge is needed to connect two or more sites for replication.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

What is assigned to the answer variable after the following code is executed? ? int answer = 0; int yNum = 0; do  {    for (int xNum = 1; xNum < 3; xNum +=1)       answer = answer * xNum;    yNum += 1; } while (yNum < 3);

A. 0 B. 6 C. 18 D. 36

Computer Science & Information Technology