Data Structures Tutorial

Data Structures Tutorial Asymptotic Notation Structure and Union Array Data Structure Linked list Data Structure Type of Linked list Advantages and Disadvantages of linked list Queue Data Structure Implementation of Queue Stack Data Structure Implementation of Stack Sorting Insertion sort Quick sort Selection sort Heap sort Merge sort Bucket sort Count sort Radix sort Shell sort Tree Traversal of the binary tree Binary search tree Graph Spanning tree Linear Search Binary Search Hashing Collision Resolution Techniques

Misc Topic:

Priority Queue in Data Structure Deque in Data Structure Difference Between Linear And Non Linear Data Structures Queue Operations In Data Structure About Data Structures Data Structures Algorithms Types of Data Structures Big O Notations Introduction to Arrays Introduction to 1D-Arrays Operations on 1D-Arrays Introduction to 2D-Arrays Operations on 2D-Arrays Strings in Data Structures String Operations Application of 2D array Bubble Sort Insertion Sort Sorting Algorithms What is DFS Algorithm What Is Graph Data Structure What is the difference between Tree and Graph What is the difference between DFS and BFS Bucket Sort Dijkstra’s vs Bellman-Ford Algorithm Linear Queue Data Structure in C Stack Using Array Stack Using Linked List Recursion in Fibonacci Stack vs Array What is Skewed Binary Tree Primitive Data Structure in C Dynamic memory allocation of structure in C Application of Stack in Data Structures Binary Tree in Data Structures Heap Data Structure Recursion - Factorial and Fibonacci What is B tree what is B+ tree Huffman tree in Data Structures Insertion Sort vs Bubble Sort Adding one to the number represented an array of digits Bitwise Operators and their Important Tricks Blowfish algorithm Bubble Sort vs Selection Sort Hashing and its Applications Heap Sort vs Merge Sort Insertion Sort vs Selection Sort Merge Conflicts and ways to handle them Difference between Stack and Queue AVL tree in data structure c++ Bubble sort algorithm using Javascript Buffer overflow attack with examples Find out the area between two concentric circles Lowest common ancestor in a binary search tree Number of visible boxes putting one inside another Program to calculate the area of the circumcircle of an equilateral triangle Red-black Tree in Data Structures Strictly binary tree in Data Structures 2-3 Trees and Basic Operations on them Asynchronous advantage actor-critic (A3C) Algorithm Bubble Sort vs Heap Sort Digital Search Tree in Data Structures Minimum Spanning Tree Permutation Sort or Bogo Sort Quick Sort vs Merge Sort

Linked List Data Structure

Linked list in DS: The linked list is a non-primitive and linear data structure. It is a list of a particular type of data element that is connected to each other, as shown in the figure.

Linked List Data Structure

The linked list represents the group of nodes in which each node has two parts. The first part represents the data, and the second part represents the pointer. The pointer part of the linked list holds the address of the next node. A linked list is a data structure whose length can be increased or decreased dynamically (in run-time). The linked list is used to create a tree and graph.

Operations of Linked list

There are following types of operations in the linked list:

  1. Creation operation: It is used to create a new node in the linked list.

Node creation function:

struct node   {      int data;       struct node *next;  };  struct node *head, *ptr;   ptr = (struct node *)malloc(sizeof(struct node *));     
  • Insertion operation: It is used to add a new node to a particular location in a specific situation. A new node can be inserted at the following locations.
  • At the beginning of the linked list
  • At the middle of the linked list
  • At the end of the linked list
  • Deletion operation: It is used to delete a node in a specific situation. A node can be deleted from the following locations.
  • At the beginning of the linked list
  • At the middle of the linked list
  • At the end of the linked list
  • Traversing Operation: This operation is used to print the values ??from a node point to another node point. In other words, traversing operations is a process in which all the nodes of a linked list are checked end-to-end. If traversing from the first node to the last node, it is called forward traversing.

The following code represents the traversing of a node in the linked list:

  void traverse(node   *head){if(head != NULL){traverse (head ->   next);printf(“%d”, head   -> data);}}
  • Display Operation: The display operation is used to print the information of each node. This operation displays the complete list of nodes.
  • Search Operation: The search operation is used to search a particular node in a linked list. A sequential search is most commonly used to search the nodes in a linked list.
  • Concatenation Operation: This operation is used to connect a node to another node in the linked list.

Representation of Linked List in the Memory

The linked list is stored in different locations in the memory. The memory is allocated dynamically for each node. Dynamic means that it is allocated when it is needed. Due to the dynamical allocation, the user can increase and decrease the size of the linked list whenever he wants. An example of a memory representation in a linked list is shown in the figure below.

Linked List Data Structure



ADVERTISEMENT
ADVERTISEMENT