Linked list
data structure which is a linear collection of data elements, called nodes, each pointing to the next node by means of a pointer From Wikipedia, the free encyclopedia
Remove ads
In computer science, a linked list is a data structure that is a linear collection of items whose order is not given by their physical placement in memory. Instead, each item links to the next item. The last item links to a terminator used to mark the end of the list.
Types of linked lists
Singly linked list
Doubly linked list
Circular linked list
Linked list algorithms
Reversing a singly linked list
Item reverseList(Item head) {
Item prev = null;
Item curr = head;
while (curr != null) {
Item following = curr.next;
curr.next = prev;
prev = curr;
curr = following;
}
return prev;
}
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads