Вы находитесь на странице: 1из 4

DATA STRUCTURES and ALGORITHM: Linked List

Linked List
Is a data structure that makes it easy to rearrange data without having to move data in memory.
A linear collection of specially designed data elements, called nodes, linked to one another by means of
pointers.

Two parts of node


1. Contains the information of the element (data).
2. Contains the address of the next node in the linked list (next).

node

linked list

linked list representation of integers

Linked list advantages

1. Linked list are dynamic data structure. That is, they can grow or shrink during the execution of a
program.
2. Efficient memory utilization: In linked list (or dynamic)representation, memory is not pre-allocated.
Memory is allocated whenever it is required. And it is deallocated (or removed) when it is not needed.
3. Insertion and deletion are easier and efficient. Linked list provides flexibility in inserting a data item at a
specified position and deletion of a data item from the given position.
4. Many complex applications can be easily carried out with linked list.

Linked list disadvantages


1. More memory: to store an integer number, a node with integer data and address field is allocated. That
is more memory space is needed.
2. Access to an arbitrary data item is little bit cumbersome and also time consuming.

Linked List Operations

Creation
Create a linked list. Once a linked list is created with one node, insertion operation can be used to add
more elements in a node.

Engr. Julius S. Cansino Page 1


DATA STRUCTURES and ALGORITHM: Linked List

Insertion
Insert a new node at any specified location in the linked list (beginning, end, or specified position
between linked list).

Deletion
Delete an item (or node) from the linked list (beginning, end, specified location of the linked list)

Traversing
Process of going through all the nodes from one end to another end of the linked list. In singly linked list
we can visit from left to right, forward traversing is nodes only. In doubly linked list forward and backward
traversing is possible.

Searching
Search values from the linked list.

Concatenation
Appending the second list to the end of the first list.

Types of linked list


1. Singly
2. Doubly
3. Circular

Engr. Julius S. Cansino Page 2


DATA STRUCTURES and ALGORITHM: Linked List

Singly Linked List


Enables a program to move through the list in one direction, which is usually from the front of the list
moving to the end of the list.

Creation (3 nodes with data value of 10, 20, and 30)

Insertion (insert node with data value of 5 at the beginning)

Engr. Julius S. Cansino Page 3


DATA STRUCTURES and ALGORITHM: Linked List

Doubly Linked List


Enables the program to move through the list in both directions.

STACK USING LINKED LIST

Engr. Julius S. Cansino Page 4

Вам также может понравиться