0

Frinds give diffrent ideas about double linked list and send code in diffrent ways

5th Nov 2018, 4:21 PM
abdullah rajpoot
abdullah rajpoot - avatar
5 Respuestas
+ 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.
5th Nov 2018, 5:00 PM
Anya
Anya - avatar
+ 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 :)
5th Nov 2018, 5:59 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 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.
5th Nov 2018, 4:43 PM
Anya
Anya - avatar
0
Anya if i want to add a newnode then how it will happend
5th Nov 2018, 4:54 PM
abdullah rajpoot
abdullah rajpoot - avatar
0
:(
5th Nov 2018, 6:32 PM
abdullah rajpoot
abdullah rajpoot - avatar