For this homework, you may assume the type definitions used in class today:
struct NodeType {
int i;
NodeType *Next;
};
NodeType *Head;
Write a function to delete the tail of a singly linked list. Assume that there is only a head pointer and no tail pointer. Use the following prototype:
void DeleteTail ();
void DeleteTail ()
{
if (Head == NULL)
{
}
else if (Head -> Next == NULL)
{
delete Head;
Head = NULL;
}
else
{
NodeType *p = Head;
while (p->Next->Next != NULL)
p = p->Next;
delete p->Next;
p->Next = NULL;
}
}