Posts

Data Structure - Logic of Singly linked list

Image
  What is a Singly linked list ? Single linked lists are linear data structures where elements are not stored in contiguous locations but they are linked using pointers. The linked list comes into picture when the data is dynamic in nature and size of data is not known initially. Here I've explained the Singly linked list from the basics so that the learner gets a better idea of it. Structure of Singly linked list           The linked lists are made up of nodes. Each node is made up of two parts : data part and address part (holds the address of the next node). Representation of a node in C/C++ language: struct Node { int data; // data part Node* link; // Address of the next node }*head; Constructing a linked list:           Let us consider 4 integers and its corresponding addresses as given in the below table. We shall construct a linked list with this data. The first node in the single linked ...