Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Identify the errors in the C function below. Select all that apply. void deleteN

ID: 3810652 • Letter: I

Question

Identify the errors in the C function below. Select all that apply.

void deleteNode(node *&head, int del)
{
    node *ptr = *head;

  if (del == head->num)
    {
        *head = (*head)->next;
        ptr->next = NULL;
        delete ptr;
        return;
    }
}

the function header

initializing ptr

moving head

deleting something that was dynamically allocated

Identify the errors in the C function below. Select all that apply.

void deleteNode(node *&head, int del)
{
    node *ptr = *head;

  if (del == head->num)
    {
        *head = (*head)->next;
        ptr->next = NULL;
        delete ptr;
        return;
    }
}

Answers:

the function header

initializing ptr

moving head

deleting something that was dynamically allocated

Explanation / Answer

Answer:

the function header and

moving head

the function header should be like below

void deleteNode(node *head, int del)

moving head should be like below

*head = head->next;