Algoritmid ja andmestruktuurid eksamiks kordamine
o Võib abiks võtta 2 viita: Current ja Prev. Viimane on pidevalt ühe elemendi võrra Curr-ist
tagapoolt. Lisamine toimub Prev-i ja Current-i vahele.
• Viimase elemendi lisamisel tuleb uue sõlme viidavälja NIL kirjutada
4.3.2 Pildiline
4.4 Elemendi kustutamine
Kustutav sõlm otsitakse tavaliselt üles infovälja või võtmevälja väärtuse järgi. Mugavam on kustutada
kasutades kahte abiviita (sarnaselt lisamisele)
We point the head to the next node and remove the node that the head pointed to.
To remove a node from the back of the linked list, we need to:
• Use two pointers: cursor and back to track the node.
• Start from the first node until the cursor pointer reaches the last node and the back pointer reaches
the node before the last node.
• Set the next pointer of the back to NULL and delete the node that the cursor points to.