Linked List Flashcards
What kind of structure is a linked list?
A dynamic data structure
What is an element in a list called?
Node
What things does a node store?
The data relating to the element
A pointer to the next node
Define traversing
To work your way systematically through the list
How do you traverse a list?
Start at the first node and follow each link until you reach the last node
can a linked list be ordered?
A linked list can be ordered or unordered
Where can you add a new node to an unordered list?
To the beginning or end of list
Is it more efficient to add nodes to the end of an unordered list?
No as you have to trans verse the list to find the last element
Steps for adding a new node to an unordered list
Create a new node
Set the pointer of the node to the value of the head pointer
Set the head pointer to the new node
Define the process for inserting a new element into a list ordered numerically
Create the new node
Traverse the list until you reach the node which has a value greater than the value of the new node
Set the value of the next pointer of the new node to the value of the next pointer of the previous node
Set the value of the next pointer of the previous node to point to the new node