Advertisement

Insertion and Deletion in Linked List in Hindi

कल्पना कीजिए कि आप एक ट्रेन डिज़ाइन कर रहे हैं, जिसमें हर डिब्बा (Node) पिछले और अगले डिब्बे से जुड़ा होता है। जब भी आपको कोई नया डिब्बा जोड़ना हो या किसी पुराने को हटाना हो, आप पूरी ट्रेन को नहीं बदलते, बस लिंक को एडजस्ट करते हैं। कुछ ऐसा ही होता है Linked List डेटा स्ट्रक्चर में, जहाँ नोड्स (जिनमें डेटा और अगले नोड का पता होता है) को जोड़ा या हटाया जा सकता है। इस ब्लॉग में हम आपको Linked List में Insertion और Deletion (Insertion and Deletion in Linked List in Hindi) की प्रक्रिया को आसान भाषा में समझाएंगे, स्टेप बाय स्टेप गाइड, और C लैंग्वेज के कोड के साथ।

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

Linked List एक लोकप्रिय डेटा स्ट्रक्चर है, जिसमें नोड्स (Nodes) की एक श्रृंखला होती है। हर नोड दो भागों में बंटा होता है:

  • डेटा: वह असली जानकारी जिसे आप स्टोर करना चाहते हैं (जैसे कोई नंबर, नाम, या टॉपिक)।
  • पॉइंटर: यह अगले नोड का पता रखता है, यानी यह एक लिंक होता है जो लिस्ट को जोड़ता है।

उदाहरण: मान लीजिए आप अपनी स्टडी नोट्स की एक सूची बना रहे हैं। हर नोड एक चैप्टर का नाम (Data) और अगले चैप्टर की जानकारी (Pointer) रखता है। इससे एक लिंक्ड स्ट्रक्चर बनता है जो चैप्टर्स को आपस में जोड़ता है।

Advertisement

Why is a linked list better in Hindi? - लिंक्ड लिस्ट बेहतर क्यों है?

Linked List में Insertion (नया नोड जोड़ना) और Deletion (पुराना नोड हटाना) आसान होता है। इसमें Array की तरह बाकी एलिमेंट्स को शिफ्ट करने की जरूरत नहीं पड़ती, जिससे ऑपरेशन तेज़ और मेमोरी-कुशल बनता है।

Insertion and Deletion in Linked List in Hindi - लिंक्ड लिस्ट में इनसर्शन और डिलीशन

Insertion in Linked List: नोड जोड़ने की प्रक्रिया

Insertion का मतलब होता है - एक नया नोड लिंक्ड लिस्ट में जोड़ना। यह प्रक्रिया तीन संभावित स्थानों पर हो सकती है:

  1. लिस्ट की शुरुआत में (Beginning)
  2. लिस्ट के अंत में (End)
  3. लिस्ट के बीच में किसी विशेष पोजिशन पर (Specific Position)

स्टेप-बाय-स्टेप प्रक्रिया (Insertion at Beginning)

  1. नया नोड बनाएं और उसमें आवश्यक डेटा स्टोर करें।
  2. नए नोड का पॉइंटर मौजूदा हेड (पहला नोड) की ओर इशारा करे।
  3. अब हेड को अपडेट कर नए नोड को पॉइंट कराएं।

उदाहरण: अगर लि

Advertisement

स्ट है [10 -> 20 -> 30], और आप 5 जोड़ना चाहते हैं, तो नई लिस्ट होगी [5 -> 10 -> 20 -> 30]।

Deletion in Linked List: नोड हटाने की प्रक्रिया

Deletion का मतलब है - लिंक्ड लिस्ट से किसी नोड को हटाना। यह तीन अलग-अलग स्थानों पर किया जा सकता है:

  • लिस्ट की शुरुआत से (Beginning Deletion)
  • लिस्ट के अंत से (End Deletion)
  • लिस्ट के बीच से किसी खास पोजिशन पर (Position-Based Deletion)

स्टेप-बाय-स्टेप प्रक्रिया (Deletion from Beginning)

    • हेड नोड को टेम्परेरी वैरिएबल में स्टोर करें।
    • हेड को अगले नोड पर शिफ्ट करें यानी नया हेड बना दें।
    • जो नोड स्टोर किया गया था, उसे डिलीट कर दें (free/delete)।

उदाहरण: अगर लिस्ट है [5 -> 10 -> 20 -> 30], और आप हेड (5) हटाते हैं, तो नई लिस्ट होगी [10 -> 20 -> 30]।

C कोड: Insertion और Deletion

नीचे Linked List में शुरुआत में Insertion और Deletion का C कोड है, जो सरल और बिगिनर-फ्रेंडली है:

Input:

 C

#include <stdio.h>
#include <stdlib.h>

// नोड की संरचना
struct Node {
    int data;
    struct Node* next;
};

// Insertion at Beginning
struct Node* insertAtStart(struct Node* head, int newData) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->data = newData;
    newNode->next = head;
    head = newNode;
    return head;
}

// Deletion at Beginning
struct Node* deleteAtStart(struct Node* head) {
    if (head == NULL) return NULL;
    struct Node* temp = head;
    head = head->next;
    free(temp);
    return head;
}

// लिस्ट प्रिंट करने के लिए
void printList(struct Node* head) {
    struct Node* current = head;
    while (current != NULL) {
        printf("%d -> ", current->data);
        current = current->next;
    }
    printf("NULL\n");
}

// मेन फंक्शन
int main() {
    struct Node* head = NULL;
    
    // Insertion
    head = insertAtStart(head, 30);
    head = insertAtStart(head, 20);
    head = insertAtStart(head, 10);
    printf("लिस्ट Insertion के बाद: ");
    printList(head);
    
    // Deletion
    head = deleteAtStart(head);
    printf("लिस्ट Deletion के बाद: ");
    printList(head);
    
    return 0;
}

Output:

Plain
लिस्ट Insertion के बाद: 10 -> 20 -> 30 -> NULL
लिस्ट Deletion के बाद: 20 -> 30 -> NULL

Description:

  • कोड में insertAtStart फंक्शन नया नोड शुरू में जोड़ता है।
  • deleteAtStart फंक्शन हेड नोड को हटाता है।
  • printList लिस्ट को प्रिंट करता है।

Linked List में Insertion और Deletion का रियल-वर्ल्ड यूज

Linked List में Insertion और Deletion का उपयोग कई जगह होता है:

Advantages:

  • डायनामिक साइज: लिस्ट को आसानी से बढ़ाया या घटाया जा सकता है।
  • तेज ऑपरेशन्स: ऐरे की तुलना में Insertion और Deletion तेज।

Disadvantages:

  • रैंडम एक्सेस नहीं: किसी खास नोड तक पहुंचने में समय लगता है।
  • ज्यादा मेमोरी: पॉइंटर्स के लिए अतिरिक्त जगह चाहिए।

उदाहरण: जब आप म्यूजिक प्लेयर में गाने की प्लेलिस्ट बनाते हैं, तो Linked List का उपयोग गाने जोड़ने (Insertion) या हटाने (Deletion) के लिए होता है।

Tips and use of the future in Hindi - टिप्स और भविष्य का उपयोग

टिप्स (Tips):

  • छोटी लिस्ट के लिए Linked List यूज करें, जहां बार-बार Insertion/Deletion हो।
  • कोड में मेमोरी लीक से बचने के लिए free का उपयोग करें।
  • डबल लिंक्ड लिस्ट यूज करें अगर पीछे की ओर मूवमेंट चाहिए।

भविष्य: Linked List का उपयोग डेटाबेस, म्यूजिक प्लेलिस्ट्स, और ब्राउज़र हिस्ट्री में होता है। भविष्य में, AI सिस्टम्स में डायनामिक डेटा मैनेजमेंट के लिए इसका महत्व बढ़ेगा।

निष्कर्ष (Conclusion)

Insertion और Deletion in Linked List डेटा को डायनामिकली मैनेज करने का एक शानदार तरीका है। ट्रेन की बोगियों की तरह, आप नोड्स को आसानी से जोड़ या हटा सकते हैं। इस ब्लॉग में हमने प्रक्रिया, और कोड के साथ इसे समझा। अगर आप 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.