0
Frinds give diffrent ideas about double linked list and send code in diffrent ways
5 Answers
+ 5
It's a little complicated but you will have 4 types of insertion
Insertion in the head
before a given node
after a given node
Insertion in end of list.
Every one you just need to point different using pointers.
You can see a very well detailed explanation here:
https://www.geeksforgeeks.org/doubly-linked-list/
Edit: If you having trouble how to write your logic the link have code example. Just understand the logic and try it first after you can look the code example.
Edit:1 If you have a specific doubt i encourage you to ask.
+ 10
abdullah rajpoot First check whether the head of Link List is empty or not, if it is then create a new node and assign its address to the head. If the head in not null (LL is not empty) then you need to iterate over each node of the list until you reach the end, and when you do then join the tail of list with newly created node.
Now I leave the things on you like how to create node and check if the head is null or not.
Read the article Anya provided you if you have any query or doubt, ask for it :)
+ 4
Oh it's double linked list. Ok every node will have a pointer point to previous element and other pointer to point to the next element.
Head previous pointer and last element next pointer will point to NULL.
Edit: For printing normally you want to receive a starting node. From there mostly easy way to pass element by element is using recursion going to next pointer (foward direction) or previous pointer(reverse direction) until the end, in other words, != NULL.
0
Anya if i want to add a newnode then how it will happend
0
:(