Question: Write a C function insertAtEnd() for a doubly linked list that has the following header: int insertAtEnd (struct node **pStart, char *pNewData); The variable pStart
Write a C function insertAtEnd() for a doubly linked list that has the following header:
int insertAtEnd (struct node **pStart, char *pNewData);
The variable pStart indirectly references the front of the list and the variable pNewData is a pointer to contiguous memory (string) that should be copied into the new node. The function must insert a new node, at the end or back of the linked list, with the data value pNewData. The function must return 1 if the node was successfully added to the end; 0 otherwise. Assume that struct node is defined as follows:
struct node
{
char *pData;
struct node *pNext; // points to next node in sequence
struct node *pPrev; // points to previous node in sequence
};
You must implement the dynamic memory allocation for a node inside of insertAtEnd(). Hint: make sure that you also allocate space for the string.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
