Advertisement

Doubly Linked List in Data Structure in Hindi - डबली लिंक्ड लिस्ट क्या है?

अगर आप कंप्यूटर साइंस या डेटा स्ट्रक्चर सीख रहे हैं, तो आपने Linked List के बारे में जरूर सुना होगा। इसमें डेटा को नोड्स की शक्ल में रखा जाता है जो एक-दूसरे से जुड़े होते हैं। Doubly Linked List, Linked List का एक विकसित रूप है, जिसमें हर नोड के पास दोनों तरफ - अगले और पिछले नोड की लिंक होती है। इससे डेटा को दोनों दिशाओं में आसानी से एक्सेस किया जा सकता है।

इस ब्लॉग में हम Doubly Linked List को सरल भाषा में समझेंगे, इसके फायदे और नुकसान जानेंगे, इसके उपयोगों पर नजर डालेंगे और अंत में एक छोटा सा C प्रोग्राम भी दिखाएंगे।

लिंक्ड लिस्ट क्या है? - What is Linked List in Hindi?

Linked List एक डेटा स्ट्रक्चर है जिसमें डेटा को स्टोर करने के लिए अलग-अलग नोड (Node) जुड़े होते हैं। हर नोड के पास होता है:

Advertisement
    1. Data - असली जानकारी
    2. Pointer - अगले नोड का पता

इसे ऐसे समझो जैसे मोतियों की माला, जहाँ हर मोती अगले मोती से धागे (pointer) के जरिए जुड़ा है।

Linked List के फायदे हैं कि इसमें डायनामिक साइज होता है और बीच में नोड जोड़ना/हटाना आसान है। लेकिन इसमें Direct Access (जैसे array में) नहीं होता, यानी किसी भी पोज़ीशन पर जाने के लिए हमें शुरू से ट्रैवर्स करना पड़ता है।

डबली लिंक्ड लिस्ट क्या है? - What is Doubly Linked List in Hindi?

Doubly Linked List में हर नोड के पास दो लिंक होते हैं, एक पिछले नोड की ओर और एक अगले नोड की ओर।

Advertisement
  1. Previous Pointer: पीछे वाले नोड का पता
  2. Next Pointer: आगे वाले नोड का पता

इससे हम किसी भी दिशा में ट्रैवर्स कर सकते हैं, आगे भी और पीछे भी।

[caption id="attachment_4803" align="aligncenter" width="600"]Doubly Linked List in Hindi Doubly Linked List in Hindi[/caption]

डबली लिंक्ड लिस्ट के लाभ - Advantages of Doubly Linked List in Hindi

  • Two-way traversal: जहां से डेटा को फॉरवर्ड और बैकवर्ड, दोनों तरफ से एक्सेस किया जा सकता है
  • Easy insertion and deletion: बीच में नोड जोड़ना/हटाना आसान है।
  • Flexibility: लास्ट नोड से भी ट्रैवर्स शुरू कर सकते हैं।

डबली लिंक्ड लिस्ट के नुकसान - Disadvantages of Doubly Linked List in Hindi

  • Extra memory usage: एक अतिरिक्त पॉइंटर की वजह से ज्यादा मेमोरी लगती है।
  • Complex code: Singly Linked List से ज्यादा पॉइंटर मैनेज करने पड़ते हैं।
  • Pointer updates: नोड एड/डिलीट करते समय दोनों पॉइंटर सही करने होते हैं।

डबली लिंक्ड लिस्ट के उपयोग - Applications of Doubly Linked List in Hindi

  1. Web Browser History Navigation (Back & Forward)
  2. Undo/Redo Feature in Editors
  3. Music Playlist Navigation
  4. Image Slideshow Navigation

डबली लिंक्ड लिस्ट का कोड उदाहरण (C भाषा में) - Code example of Doubly Linked List (in C language) in Hindi

Input:

 C

#include 
#include 

// Node structure
struct Node {
    int data;
    struct Node* prev;
    struct Node* next;
};

// Function to create a new node
struct Node* createNode(int data) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->data = data;
    newNode->prev = NULL;
    newNode->next = NULL;
    return newNode;
}

// Function to print the list forward
void displayForward(struct Node* head) {
    struct Node* temp = head;
    printf("Forward: ");
    while (temp != NULL) {
        printf("%d ", temp->data);
        temp = temp->next;
    }
    printf("\n");
}

// Function to print the list backward
void displayBackward(struct Node* tail) {
    struct Node* temp = tail;
    printf("Backward: ");
    while (temp != NULL) {
        printf("%d ", temp->data);
        temp = temp->prev;
    }
    printf("\n");
}

int main() {
    // Create three nodes
    struct Node* head = createNode(10);
    struct Node* second = createNode(20);
    struct Node* third = createNode(30);

    // Connect the nodes
    head->next = second;
    second->prev = head;
    second->next = third;
    third->prev = second;

    // Display the list in both directions
    displayForward(head);
    displayBackward(third);

    return 0;
}

Output of the Program:

जब आप ऊपर वाला Doubly Linked List प्रोग्राम रन करेंगे, तो आउटपुट कुछ इस तरह होगा:

Plain
Forward: 10 20 30 
Backward: 30 20 10 

Doubly Linked List vs Singly Linked List in Hindi

Feature Singly Linked List Doubly Linked List
Traversal Direction Forward only Forward & Backward
Memory Usage Less More (extra pointer)
Insertion/Deletion Speed Moderate Faster in middle operations
Complexity Simple Slightly Complex

निष्कर्ष - Conclusion

Doubly Linked List एक प्रभावी डेटा स्ट्रक्चर है, जो हमें दोनों दिशाओं में डेटा नेविगेट करने की क्षमता प्रदान करता है। यह खासतौर पर उन परिस्थितियों में उपयोगी होता है, जहां नोड्स को तेज़ी से आगे-पीछे ट्रैवर्स करना हो या बीच में बदलाव करना हो। हालांकि, इसके लिए थोड़ी ज्यादा मेमोरी और सावधानी की जरूरत होती है। इसलिए Doubly Linked List सीखना आपके प्रोग्रामिंग कौशल को अगले स्तर तक पहुंचाने में मदद करेगा।

Table of Contents

Close

Comments

Share to other apps

Report Content

Why are you reporting this content?

Your selection helps us review the content and take appropriate action.

Hate & Discrimination
Content that spreads hate or unfair treatment against a person or group because of who they are.
Abuse & Harassment
Content that insults, threatens, bullies, or makes someone uncomfortable.
Violence & Threats
Content that talks about hurting people, animals, or property, or supports violence.
Child Safety
Any content that harms, exploits, or puts children at risk.
Privacy Violation
Sharing someone’s personal information or photos without permission.
Illegal & Regulated Activities
Content that promotes or helps with illegal activities like drugs, weapons, or trafficking.
Spam & Misleading Content
Fake, misleading, or repeated content meant to trick users.
Suicide or Self-Harm
Content that encourages or explains self-harm or suicide.
Sensitive or Disturbing Content
Shocking or graphic content that may upset users.
Impersonation
Pretending to be another person or organization.
Extremism & Hate Groups
Content that supports violent groups or hateful ideas.
Civic Integrity
Content that spreads false information about elections or public processes.