Untitled
unknown
plain_text
8 months ago
1.3 kB
10
Indexable
#include <stdio.h>
#include <stdlib.h>
// ডাবলি লিংকড লিস্টের জন্য নোড স্ট্রাকচার
struct Node {
int data;
struct Node* prev;
struct Node* next;
};
int main() {
// ৭, ১১, এবং ৯ নামে তিনটি নোড তৈরি
struct Node* head = (struct Node*)malloc(sizeof(struct Node));
struct Node* temp = (struct Node*)malloc(sizeof(struct Node));
struct Node* second = (struct Node*)malloc(sizeof(struct Node));
// ডাটা সেট করা
head->data = 7;
head->prev = NULL;
head->next = temp;
temp->data = 11;
temp->prev = head;
temp->next = second;
second->data = 9;
second->prev = temp;
second->next = NULL;
// **নোড ১১ ডিলিট করা**
head->next = temp->next; // ৭-এর `next` কে ৯-এ সেট করা
second->prev = head; // ৯-এর `prev` কে ৭-এ সেট করা
free(temp); // মেমোরি ডি-অ্যালোকেট করা
// Doubly Linked List এর নতুন অবস্থা প্রিন্ট করা
printf("NULL <-> %d <-> %d <-> NULL\n", head->data, second->data);
return 0;
}
Editor is loading...
Leave a Comment