Self Referential Structures
Self Referential structures are those structures that have one or more pointers which point to the same type of structure, as their member. Show In other words, structures pointing to the same type of structures are self-referential in nature.
CPP
Python3
In the above example ‘link’ is a pointer to a structure of type ‘node’. Hence, the structure ‘node’ is a self-referential structure with ‘link’ as the referencing pointer.
Self Referential Structure with Single Link: These structures can have only one self-pointer as their member. The following example will show us how to connect the objects of a self-referential structure with the single link and access the corresponding data members. The connection formed is shown in the following figure. CPP
Python3
Output: 30 40 Self Referential Structure with Multiple Links: Self referential structures with multiple links can have more than one self-pointers. Many complicated data structures can be easily constructed using these structures. Such structures can easily connect to more than one nodes at a time. The following example shows one such structure with more than one links. CPP
Python3
Output: 10 20 30 10 20 30 10 20 30 In the above example we can see that ‘ob1’, ‘ob2’ and ‘ob3’ are three objects of the self referential structure ‘node’. And they are connected using their links in such a way that any of them can easily access each other’s data. This is the beauty of the self referential structures. The connections can be manipulated according to the requirements of the programmer.
Article Tags : Data Structures Practice Tags : Data Structures Linked List Data Structure
Practice Problems on Linked List A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers as shown in the below image: In simple words, a linked list consists of nodes where each node contains a data field and a reference(link) to the next node in the list. Topics :
Singly Linked List :
More >> Circular Linked List :
More >> Doubly Linked List :
More >> Misc :
Quick Links :
If you still need more assistance with your placement preparation, have a look at our Complete Interview Preparation Course. The course has been designed by our expert mentors to help students crack the coding interview of top product or service-based organizations . You get access to premium lectures, 200+ coding questions bank, resume building tips, and lifetime access to the course content. So to make sure that your next programming interview doesn’t feel like an interrogation, enroll in Complete Interview Preparation and give a boost to your placement preparation. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. Linked list Data StructureIn this tutorial, you will learn about linked list data structure and it's implementation in Python, Java, C, and C++. A linked list is a linear data structure that includes a series of connected nodes. Here, each node stores the data and the address of the next node. For example, You have to start somewhere, so we give the address of the first node a special name called HEAD. Also, the last node in the linked list can be identified because its next portion points to NULL. Linked lists can be of multiple types: singly, doubly, and circular linked list. In this article, we will focus on the singly linked list. To learn about other types, visit Types of Linked List. Note: You might have played the game Treasure Hunt, where each clue includes the information about the next clue. That is how the linked list operates. Linked List in A Data Structure: All You Need to KnowLesson 3 of 54By Simplilearn Last updated on Sep 19, 20216018PreviousNext
Table of ContentsView MoreA linked list is the most sought-after data structure when it comes to handling dynamic data elements. A linked list consists of a data element known as a node. And each node consists of two fields: one field has data, and in the second field, the node has an address that keeps a reference to the next node. |