Forward And Backword Linked List With Example

Explain Forward And Backword Linked List With Example

Steps to build a linked list forward:


Create a new node called newNode
If first is NULL, the list is empty so you can make first and last point to newNode
If first is not NULL make last point to newNode and make last = newNode

What is needed to build a linked list backwards


a pointer for the first node
a pointer to the new node being added

Steps to build a linked list backwards:


Create a new node newNode
Insert newNode before first
Update the value of the pointer first



Labels: