+ 2

Multi linked list

How to delete a node from a list

8th Aug 2018, 10:48 PM
Saya
1 ответ
+ 2
assuming the linked list is a -> b -> c -> d -> e if you want to delete node c just do this: >>> b.next = b.next.next the "next" property restore the next node so before you do this "b.next" is "c" and "b.next.next", also "c.next", is "d" then we want "b.next" to restore "d", and it is "b.next.next" therefore, we do this: >>> b.next = b.next.next now, b is linked to d, and c is missed unless you have stored it with another variable
9th Aug 2018, 2:27 PM
Flandre Scarlet
Flandre Scarlet - avatar