top of page

Summary of Linked List

  • Writer: Rhenald Ariendra
    Rhenald Ariendra
  • Feb 25, 2020
  • 2 min read

ree

Definition of Linked List

Linked list is sequence of data that are connected through a link. Linked list the second most used data structure after array. Linked list contains of head that store the first address of the link, node that used to store the data you want to store and a link to the next data, and in the last data the link should be NULL.


There are 3 types of linked list :

1. Single linked list

2. Double linked list

3. Circular linked list


Basic Operator in a Linked List

There are some basic operators that you can use in a linked list :

1. Insert

Basically insert is an operator that you use to insert a variable.

2. Delete

This operator let you delete data that you want to delete.

3. Display

This operator will display all the linked list that you already store.

4. Search

This operator will let you search data and display only the data that you want to search.


Single Linked List


Single linked list is a list that only connected to the next link, so we can only navigate it forward. Below is an illustration of single linked list.

ree

And here is how to create a single linked list in C.

ree

Here is some code of to insert and delete element of single linked list.

ree

Notes : root is the same as head in the illustration above.

ree

Notes : the code above is to delete a data in a certain position (the position will start with index of 0 same with an array).


Double Linked List


Double linked list is a list of data that link to the next and previous data if present. So it is different than single linked list we can navigate it forward and backward. Below is an illustration of double linked list.

ree

And here is how to create a double linked list in C.

ree

Below are some codes to delete and insert data of a double linked list,

ree

ree

Circular Linked List


Circular linked list is a linked list where the last link contains the first element of the first element and the first link also has the element of the last link. Circular linked list can based on single linked list and double linked list. Below are illustrations of circular single linked list and circular double linked list.

ree
ree

References :

1. Power point of linked list (I) & linked list (II)


For the Image Sources :




Comments


bottom of page