Q: WAP to delete node in singly linked list when position and start pointer is given. Without using extra pointer
Q: WAP to reverse a singly linked list
Q: WAP to delete a node of singly linked list if only address on that node is given
Q : WAP to find nth node from the last in a singly linked list
Q: WAP to add all node value within a given range in SLL
Q: WAP to add all nodes value in a given SLL between the range from last i.e add all nodes form 2nd to 4th position from last.
Q: WAP to find common data position in two different given Singly Linked lists.
Q: Find middle node of given singly linked list
Q: WAP to detect loop in a singly linked list
Q: Binary Tree insertion, Deletion, traversal and searching
Q: WAP to reverse a singly linked list
Q: WAP to delete a node of singly linked list if only address on that node is given
Q : WAP to find nth node from the last in a singly linked list
Q: WAP to add all node value within a given range in SLL
Q: WAP to add all nodes value in a given SLL between the range from last i.e add all nodes form 2nd to 4th position from last.
Q: WAP to find common data position in two different given Singly Linked lists.
Q: Find middle node of given singly linked list
Q: WAP to detect loop in a singly linked list
Q: Binary Tree insertion, Deletion, traversal and searching
what algorithm has to use for programme delete the second last node from the list.
ReplyDeletethe best way to delete second last node in single traverse
Deletevoid delete_second_last_node(my_list_t *node)
{
my_list_t *temp = node;
my_list_t *cur = NULL;
while(temp->next->next != NULL)
{
cur = temp;
temp = temp->next;
}
cur->next = temp->next;
free(temp);
}
How to find middle node from double linked list.When we are passing start address and last node address.
DeleteWhat is use of conditional variable with mutex operation.
DeleteHi Raghwendra
DeleteTo Finding a middle node in doubly list is quite easy when you are passing Start and Last node address. But one thing we should keep in mind in order to finding a middle node. Middle node certain in case of DLL with odd number of nodes. where as in even number of nodes DLL, Situation is changed. So to meet all odd even nodes issue we need to put two conditions
while ( start != NULL && end != NULL)
{
if ( start == end )
{
// Any of node either start or end, can be middle node
// Because both are pointing same node. i.e middle node
} else if ( start->prev == end->next) {
// Any of node either start or end, can be middle node. Because this condition will become true only when it is a even node DLL
}
start = start->next;
end = end->prev;
}