[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.
Interview Questions and Answers :: Broadcom Ltd

3. How to delete a node in linklist, when one address of that node is given.

Answer:

void deleteNodeWithoutHead(struct Node* pos)
{
if (*pos == NULL) // If linked list is empty
return;

else {
struct Node* temp = pos->next;

// Copy data of the next node to current node
pos->data = pos->next->data;

// Perform conventional deletion
pos->next = pos->next->next;

free(temp);
}
return 0;
}

Post Your Answer Here:      Public      Private

Rate This: +1 -0
Report     

Post Your Reply Here:     

Report Error

Report Error

Please Login First Click Here