Posts

Showing posts with the label Linked List

Self-Referential Structure सेल्फ रेफरेंशियल स्ट्रक्चर

If a structure defines one or more pointer variables of the same structure type as its data members, it is called a self-referential structure. In other words, a self-referential structure contains a pointer member which can point to another structure variable of the same type. यदि एक स्ट्रक्चर अपने डेटा मेंबर्स के रूप में उसी प्रकार के एक या अधिक पॉइंटर वेरिएबल्स रखता है, तो उसे सेल्फ रेफरेंशियल स्ट्रक्चर (Self-Referential Structure) कहा जाता है। दूसरे शब्दों में, सेल्फ रेफरेंशियल स्ट्रक्चर में एक ऐसा पॉइंटर मेंबर होता है जो उसी प्रकार के किसी अन्य स्ट्रक्चर वेरिएबल को पॉइंट कर सकता है। Syntax: struct structure_name { data_type member1; data_type member2; struct structure_name *pointer_name; }; Example: struct node { int info; struct node *link; }; Explanation: In the above example: struct node is a structure type. info is an integer data member. link is a pointer member of type struct node * . link can store the address of another structure variable of type s...