লিংকড লিস্ট ডাইনামিক মেমরি অ্যালোকেশন ব্যবহার করে অর্থাৎ সেগুলো সেই অনুযায়ী বড় ও ছোট হয়। এগুলো নোডের একটি সংগ্রহ হিসেবে সংজ্ঞায়িত হয়। এখানে, নোডের দুটি অংশ রয়েছে, যেগুলো হলো ডেটা এবং লিংক। ডেটা, লিংক এবং লিংকড লিস্টের রিপ্রেজেন্টেশন নিচে দেওয়া হলো:

লিংকড লিস্টে অপারেশন
C ভাষায় লিংকড লিস্টে তিনটি ধরণের অপারেশন রয়েছে:
- ইনসার্শন (Insertion)
- ডিলিশন (Deletion)
- ট্রুভার্সিং (Traversing)
ডিলিশন (Deletion)
নিচের উদাহরণটি বিবেচনা করুন:
নোড ২ ডিলিট করুন

নোড ১ ডিলিট করুন

নোড ৩ ডিলিট করুন

প্রোগ্রাম
লিংকড লিস্টে এলিমেন্ট ডিলিশনের C প্রোগ্রাম:
#include <stdio.h> #include <stdlib.h> struct Node{ int data; struct Node *next; }; void push(struct Node** head_ref, int new_data){ struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); new_node->data = new_data; new_node->next = (*head_ref); (*head_ref) = new_node; } void deleteNode(struct Node **head_ref, int position){ //if list is empty if (*head_ref == NULL) return; struct Node* temp = *head_ref; if (position == 0){ *head_ref = temp->next; free(temp); return; } for (int i=0; temp!=NULL && i<position-1; i++) temp = temp->next; if (temp == NULL || temp->next == NULL) return; struct Node *next = temp->next->next; free(temp->next); // Free memory temp->next = next; } void printList(struct Node *node){ while (node != NULL){ printf(" %d ", node->data); node = node->next; } } int main(){ struct Node* head = NULL; push(&head, 7); push(&head, 1); push(&head, 3); push(&head, 2); push(&head, 8); puts("Created List: "); printList(head); deleteNode(&head, 3); puts("\n List after Deletion at position 3: "); printList(head); return 0; }
আউটপুট
উপরোক্ত প্রোগ্রামটি এক্সিকিউট করলে নিচের ফলাফলটি দেখায়:
Created List: 8 2 3 1 7 List after Deletion at position 3: 8 2 3 7