Linked List Flashcards
A ______ is a fundamental data structure in computer science. It consists of nodes
where each node contains _______ and ______ to the next node in the
sequence.
linked list
data and a reference (link)
Linked Lists allows for ________ and efficient insertion and
deletion operations compared to arrays
dynamic memory allocation
insertion
A linked list is a _________ that stores a collection of data elements
_______.
linear data structure
dynamically.
_______ represent those data elements, and ________ connect each node.
nodes
links or pointers
Each node consists of two fields, the ____________ and a pointer that
stores the address of its next node.
information stored in a linked list
The last node contains _____ in its second field because it will point to no node
null
A linked list can ______ and _____ its size, as per the requirement.
grow and shrink
In the linked list there is a ______, which points to the first element of the linked list,
and if the list is empty then it simply points to ______
head pointer
null or nothing.
Advantages of Linked Lists
Dynamic size
Efficient Insertion and Deletion
Memory Efficiency
Dynamic size
Linked lists do not have a _______, so you can add or remove elements as needed, without
having to worry about the size of the list. This makes linked lists a great choice when you
need to work with a collection of items whose size can change dynamically.
fixed size
Efficient Insertion and Deletion
Inserting or deleting elements in a linked list is _________, as you only need to modify
the reference of the next node.
fast and efficient
Disadvantages of Linked Lists
Slow Access Time
Pointers
Extra memory required
Slow Access Time: Accessing elements in a linked list can be ______, as you
need to traverse the linked list to find the element you are looking for.
slow
Pointers: Linked lists use _____ to reference the next node, which can make
them more ______ to understand and use compared to arrays. This
complexity can make linked lists more difficult to debug and maintain.
pointers
complex
Extra memory required: Linked lists require an _____ for each node,
which takes up _______. This can be a problem when you are working
with large data sets, as the extra memory required for the pointers can
quickly add up
extra pointer
extra memory
Traversal of items can be done in the forward direction only due to
the linking of every node to its next node.
Singly/Single Linked List
Insert a Node at the Front/Beginning of Linked List
Make the first node of Linked List linked to the new node
Remove the head from the original first node of Linked List
Make the new node as the Head of the Linked List
Insert a Node after a Given Node in Linked List
Check if the given node exists or not.
If it do not exists,
______________
If the given node exists,
_______
terminate the process.
Make the element to be inserted as a new node
Change the next pointer of given node to the new node
Now shift the original next pointer of given node to the next
pointer of new node
Insert a Node at the end of the Linked List
Go to the last node of the Linked List
Change the next pointer of last node from NULL to the new node
Make the next pointer of new node as NULL to show the end
of Linked List
you define a function that deletes a node from a linked list by calling
itself recursively until the node to be deleted is found.
recursive deletion,
ARRAY
Arrays are stored in _________.
______ in size.
Memory is allocated at ________.
Uses ______ memory than linked lists.
Elements can be accessed ______.
Insertion and deletion operation _____.
contiguous location
Fixed
compile time
less
easily
takes time.
Linked lists
are not stored in _________.
_____ in size.
_______ is allocated at run time.
Uses ______ memory because it stores both __________ of the next node.
Element accessing requires the ______ of the whole linked list.
Insertion and deletion operation is _______.
contiguous location
Dynamic
Memory
more
data and the address
traversal
faster