Skip to main content

Linked List


Linked List a sequence of data structure connected together via links.

In C a list is usually composed of multiple type of data so we usually use struct so that we can insert multiple amount of data into a single list, also our list also contain a reference(pointer in C) to the next list. So because of this reference our list linked to one another and that is also why this is called linked list. Also in linked list there is another reference that is Head and Tail. Head point to the first list in our linked list and Tail point to the last of our list in the linked list.

Now Linked List usually have 2 type that is :
1. Single Linked List
2. Double/Doubly Linked List

Single Linked List

A single linked list have only one reference that is a reference to the next list. So we could think that a single linked list is like an array. 

Linked List

As seen a single linked list only contain one reference that point to the next list. Also in our tail the next pointer is null because there is no more list.

Double Linked List

A double linked list a linked list but unlike single linked list a double linked list a 2 reference(pointer) to other list, that is Previous and Next. 
dll
As seen above the Previous reference point to the list before it and the Next reference point to the next list. The head of course have a null Previous reference because it is the first list and the tail have a null Next reference because it is the last list.

Operation

In linked list there can be found several operation :
1. Traversal : Accesses every data in the linked list, usually for searching, inserting, or deleting
2. Search : We use a linear search method to traverse the list and search for the wanted data
3. Insert : Add a new data to the linked list, There are several method of insertion that is :
  • Push Head : Insert a new data as the new head(first)
  • Push Tail : Insert a new data as the new tail(last)
  • Push Mid : Insert a new data in the middle of our linked list
4. Delete : Erase a data from our linked list, There also several mehod of deletion :
  • Pop Head : Delete the first(head) data
  • Pop Tail : Delete the last(tail) data
  • Pop Mid : Delete A data that is specified by the user
 There are also several term that is used on linked list :
1. Push : Insert
2. Pop : Delete
3. Traverse : Accessing data

Bibliography


Comments

Popular posts from this blog

Stack & Queue Stack Stack is type of data structure that store it's data in an orderly manner. Data in stack can only be removed and added from one end of the data. This is called LIFO (Last in First Out) Meaning that the last data that enter will be the first one to be removed. Stack can be implemented with array or linked list. Stack is usually used in backtracking algorithm and also used when making a recursive function (Depth First Search). Queue Queue is also a type of data structure but it's main difference from stack is that in queue data can only be added from behind and data can only be removed from the front of the queue just like a real life queue. This is called FIFO (First In First Out) meaning that the first data that is inserted will be the one that is removed first. Also like stack queue can be implemented with array or linked list. Now queue is used in an algorithm called Breath First Search. Queue also have another type called Circular Que...

AVL dan B-Tree

AVL TREE In Computer Science term an AVL tree is a type of self-balancing binary tree. The word AVL come from it's inventor  A delson- V elsky and  L andis. It's the first of such Data Structure. The term self-balancing mean that an AVL tree will maintain both of it's subtree height so that their height diffenrence will be 1, -1, or 0. This is called the balance facotr of an AVL tree. Basically an AVL tree is like an Binary Search Tree but with an self-balancing function built into it.  Why Use an AVL Tree The reasoning to why we must balance the tree if it's not balanced is so that the time complexity for the operation (Search, Insert, Delete) will always be at O(log n) instead of the usual O(h) (where h is the height of the tree ) for the worst case scenario.  Example of a skewed tree For the tree above say that we want to search for the node 74 that we have to traverse the entire tree to find said note but if it's an AVL tree then We on...