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 struct node.

उपरोक्त उदाहरण में:

  • struct node एक स्ट्रक्चर टाइप है।

  • info एक इन्टिजर डेटा मेंबर है।

  • link एक struct node * टाइप का पॉइंटर मेंबर है।

  • link उसी प्रकार के किसी अन्य स्ट्रक्चर वेरिएबल struct node का एड्रेस स्टोर कर सकता है।

Important Note:

Self-referential structures are commonly used to create dynamic data structures such as:

  • Linked List

  • Stack

  • Queue

  • Tree

  • Graph

सेल्फ रेफरेंशियल स्ट्रक्चर का प्रयोग सामान्यतः डायनामिक डेटा स्ट्रक्चर बनाने के लिए किया जाता है, जैसे:

  • लिंक्ड लिस्ट

  • स्टैक

  • क्यू

  • ट्री

  • ग्राफ

Comments

Popular posts from this blog

C Language Topics in Hindi and English

Top High-Paying Tech Skills to Learn in 2025

Complete C Programming Syllabus | Advanced C Roadmap for Students