Singly Linked List: Node Structure, Head Pointer, Null Reference Notes in Hindi & English : सिंगली लिंक्ड लिस्ट: नोड संरचना, डेटा और नेक्स्ट पॉइंटर और 20 महत्वपूर्ण MCQ प्रश्न (Rajasthan IT Exam)

Post a Comment

PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Singly Linked List: Node Structure, Head Pointer, Null Reference (सिंगली लिंक्ड लिस्ट: नोड संरचना, डेटा और नेक्स्ट पॉइंटर) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।

Overview: A Singly Linked List (SLL) is a dynamic linear data structure composed of non-contiguous heap-allocated nodes, where each node stores a data payload alongside a single next pointer referencing its successor. Traversal begins strictly at the head pointer and stops at the sentinel NULL reference in the tail node, permitting dynamic O(1) structural growth at the cost of O(n) sequential indexing and per-node pointer overhead.

अध्याय सार: सिंगली लिंक्ड लिस्ट (SLL) एक डायनामिक रेखीय डेटा संरचना है जिसमें नोड्स मेमोरी में अलग-अलग (Non-contiguous) स्थानों पर रहते हैं और प्रत्येक नोड डेटा के साथ अगले नोड का पता रखने वाला एक next पॉइंटर रखता है। ट्रैवर्सल हमेशा head पॉइंटर से शुरू होकर अंतिम नोड के NULL मान पर समाप्त होता है; इसमें आकार की सीमा नहीं होती पर रैंडम एक्सेस में O(n) समय और प्रति नोड अतिरिक्त पॉइंटर मेमोरी लगती है।

Singly Linked List: Node Structure, Head Pointer, Null Reference: Detailed Notes & Architecture (सिंगली लिंक्ड लिस्ट: नोड संरचना, डेटा और नेक्स्ट पॉइंटर)

1. Self-Referential Node Structure in C & Memory Anatomy (C में सेल्फ-रेफरेंशियल नोड संरचना और मेमोरी बनावट)

[EN] Each Singly Linked List node is implemented in C as a self-referential structure containing data field(s) and a pointer to the same struct type: struct Node { int data; struct Node *next; };. Note that a struct CANNOT directly embed a non-pointer member of its own type (struct Node next;) because that would imply infinite recursive size at compile time; embedding a pointer works because pointer size is fixed (4 bytes on 32-bit, 8 bytes on 64-bit systems).

[HI] सिंगली लिंक्ड लिस्ट के प्रत्येक नोड को C में सेल्फ-रेफरेंशियल स्ट्रक्चर से बनाते हैं: struct Node { int data; struct Node *next; };। कोई स्ट्रक्चर अपने ही प्रकार का सीधा वेरिएबल (struct Node next;) नहीं रख सकता क्योंकि इससे अनंत आकार की त्रुटि आएगी, परंतु उसी टाइप का पॉइंटर (*next) रख सकता है क्योंकि पॉइंटर का आकार निश्चित (32-बिट पर 4 बाइट या 64-बिट पर 8 बाइट) होता है।

2. Head Pointer Semantics, Empty List & Single-Node States (Head पॉइंटर की भूमिका, खाली लिस्ट व एकल-नोड स्थिति)

[EN] Unlike arrays where the array name holds a contiguous base, a Singly Linked List relies completely on an external head pointer storing the heap address of the very first node. An empty list is uniquely represented by head == NULL, whereas a single-node list satisfies head != NULL && head->next == NULL. Losing or accidentally overwriting head without saving a backup immediately orphans the entire list in heap RAM, causing a catastrophic memory leak.

[HI] लिंक्ड लिस्ट के पहले नोड का पता हमेशा एक बाहरी head पॉइंटर में सुरक्षित रहता है। जब लिस्ट खाली होती है तो head == NULL होता है, और जब केवल एक नोड हो तो head != NULL तथा head->next == NULL होता है। ट्रैवर्सल करते समय कभी भी सीधे head को आगे नहीं बढ़ाना चाहिए, वरना लिस्ट के शुरुआती नोड्स का पता खोकर मेमोरी लीक हो जाता है।

3. Sentinel NULL Reference & Per-Node Pointer Overhead (अंतिम NULL रेफरेंस और प्रति-नोड पॉइंटर मेमोरी ओवरहेड)

[EN] The final (tail) node stores NULL in its next field as an explicit sentinel marker signaling list termination; failing to initialize tail->next = NULL leaves a wild/garbage pointer that causes segmentation faults during traversal. Because every node allocates extra bytes for the next pointer (e.g., 4 bytes data + 4 bytes pointer = 8 bytes on 32-bit, or 4B int + 4B padding + 8B pointer = 16 bytes on 64-bit aligned systems), SLLs consume more memory per element than pure arrays.

[HI] अंतिम नोड के next पॉइंटर में NULL रखा जाता है ताकि लूप को पता चले कि लिस्ट समाप्त हो गई है; इसे NULL न करने पर अमान्य पते के कारण Segmentation Fault आ सकता है। हर नोड को डेटा के साथ next पॉइंटर भी स्टोर करना पड़ता है (जैसे 32-बिट पर 4B int + 4B पॉइंटर = 8 बाइट्स), जिससे एरे की तुलना में प्रति तत्व अधिक मेमोरी खर्च होती है।

4. Singly Linked List vs Contiguous Array: Access, Cache & Algorithms (सिंगली लिंक्ड लिस्ट बनाम एरे: एक्सेस समय, कैश व एल्गोरिदम सीमाएं)

[EN] Because SLL nodes are allocated individually via malloc() at scattered heap addresses, finding the k-th element requires traversing k hops from head in O(k) (O(n) worst-case) time—making O(1) random access impossible and degrading Binary Search on a sorted SLL to O(n) time. Furthermore, chasing scattered heap pointers suffers frequent CPU cache misses compared to contiguous arrays, while unidirectional links prevent backward traversal without a stack or recursion.

[HI] चूँकि लिंक्ड लिस्ट के नोड्स हीप में बिखरे होते हैं, इसलिए k-वें तत्व तक पहुँचने में head से क्रमशः चलकर O(k) (वर्स्ट-केस O(n)) समय लगता है और O(1) रैंडम एक्सेस नहीं मिलता। इसी कारण सॉर्टेड SLL पर भी बाइनरी सर्च O(n) हो जाती है, CPU कैश मिस बढ़ते हैं, और केवल आगे की दिशा (Unidirectional) में ही ट्रैवर्सल संभव होता है।

Syntax, Formula & Technical Example (Singly Linked List: Node Structure, Head Pointer, Null Reference)

#include <stdio.h>
#include <stdlib.h>
struct Node { int data; struct Node *next; };

int main(void) {
    struct Node *head = (struct Node *)malloc(sizeof(struct Node));
    struct Node *n2   = (struct Node *)malloc(sizeof(struct Node));
    head->data = 10; head->next = n2;
    n2->data   = 20; n2->next   = NULL;       // Sentinel marks end of list
    for (struct Node *cur = head; cur != NULL; cur = cur->next)
        printf("%d -> ", cur->data);          // Outputs: 10 -> 20 ->
    return 0;
}

Singly Linked List: Node Structure, Head Pointer, Null Reference Quick Reference & Comparison Table

SLL ComponentTechnical FunctionMemory & Exam Detail
Self-Referential StructPairs data payload with struct Node *next pointerCannot hold direct struct Node member (infinite size)
Head PointerStores memory address of first node; NULL if emptyMust never be overwritten directly during traversal
Tail NULL ReferenceSentinel stored in last node's next pointerTerminates traversal loops cleanly without segfaults
Random Index AccessSequential O(n) hop-by-hop traversal from headExtra pointer per node reduces CPU cache locality

Singly Linked List: Node Structure, Head Pointer, Null Reference Top 20 Bilingual MCQs with Answers

Q1. What does a single node in a standard Singly Linked List contain?

(एक सामान्य सिंगली लिंक्ड लिस्ट के प्रत्येक नोड में मुख्यतः कौन से दो भाग होते हैं?)

(A) An index integer holding the array base address

(B) Only a data value with no pointers

(C) One or more data fields and one pointer referencing the next node

(D) Two pointers referencing both previous and next nodes

Correct Answer: (C)

[EN] Each SLL node stores its data payload along with a single next pointer to the succeeding node.

[HI] सिंगली लिंक्ड लिस्ट के प्रत्येक नोड में डेटा फ़ील्ड और अगले नोड का पता रखने वाला एक next पॉइंटर होता है।

Q2. How is an EMPTY Singly Linked List conventionally represented in C/C++?

(C/C++ में एक खाली (Empty) सिंगली लिंक्ड लिस्ट को किस शर्त द्वारा दर्शाया जाता है?)

(A) sizeof(head) == 0

(B) head->data == 0

(C) head == NULL

(D) head->next == head

Correct Answer: (C)

[EN] When no nodes exist in the list, the head pointer holds NULL.

[HI] जब लिस्ट में कोई भी नोड न हो, तब head पॉइंटर का मान NULL होता है।

Q3. Which condition uniquely identifies a Singly Linked List containing EXACTLY ONE node?

(कौन सी शर्त यह निश्चित करती है कि सिंगली लिंक्ड लिस्ट में ठीक एक (Exactly One) नोड मौजूद है?)

(A) head != NULL && head->next != NULL

(B) head == NULL

(C) head != NULL && head->next == NULL

(D) head->next == head

Correct Answer: (C)

[EN] The list is non-empty (head != NULL) and the single node is also the tail (head->next == NULL).

[HI] पहला नोड मौजूद है (head != NULL) और वही अंतिम नोड भी है (head->next == NULL)।

Q4. Why is writing struct Node { int data; struct Node next; }; a compile-time error in C, whereas struct Node *next; compiles cleanly?

(C में struct Node { int data; struct Node next; }; पर कंपाइल एरर क्यों आता है, जबकि struct Node *next; सही चलता है?)

(A) A non-pointer member creates an infinitely recursive type size, whereas a pointer has fixed architecture size

(B) Structures can only hold pointers and never int variables

(C) The keyword struct cannot appear inside curly braces

(D) C prohibits structures from holding more than one variable

Correct Answer: (A)

[EN] The compiler cannot determine finite sizeof(struct Node) if it embeds itself by value, whereas a pointer always has known fixed size.

[HI] सीधा वेरिएबल रखने से नोड का आकार अनंत (Infinite) हो जाता है, जबकि पॉइंटर का आकार सिस्टम के अनुसार निश्चित होता है।

Q5. On a 32-bit machine (where sizeof(int) = 4 bytes and any pointer = 4 bytes), how many total bytes does each node struct Node { int data; struct Node *next; }; occupy?

(32-बिट सिस्टम (जहाँ int = 4 बाइट और पॉइंटर = 4 बाइट) पर struct Node { int data; struct Node *next; }; के एक नोड का कुल आकार कितना होगा?)

(A) 8 bytes

(B) 4 bytes

(C) 12 bytes

(D) 16 bytes

Correct Answer: (A)

[EN] 4 bytes for int data + 4 bytes for struct Node *next = 8 bytes per node.

[HI] 4 बाइट्स int डेटा + 4 बाइट्स पॉइंटर = कुल 8 बाइट्स प्रति नोड।

Q6. What is the time complexity of accessing the k-th element (by 0-based position) in a Singly Linked List of n nodes?

(n नोड्स वाली सिंगली लिंक्ड लिस्ट में k-वें स्थान के नोड तक पहुँचने की वर्स्ट-केस टाइम कॉम्प्लेक्सिटी क्या होती है?)

(A) O(n)

(B) O(n log n)

(C) O(1)

(D) O(log n)

Correct Answer: (A)

[EN] Without contiguous storage, reaching index k requires following k next links sequentially from head, taking O(n) worst-case time.

[HI] मेमोरी सटी न होने के कारण head से एक-एक करके लिंक पार करने पड़ते हैं, जिससे अधिकतम O(n) समय लगता है।

Q7. Why is Binary Search inefficient (taking O(n) time) on a sorted Singly Linked List?

(सॉर्टेड सिंगली लिंक्ड लिस्ट पर भी बाइनरी सर्च O(log n) के बजाय O(n) समय क्यों लेती है?)

(A) Because NULL pointers break mid-point comparisons

(B) Because linked lists cannot store sorted numbers

(C) Because malloc() always sorts nodes in reverse

(D) Because finding the middle node at each step requires linear O(n) pointer traversal instead of O(1) arithmetic

Correct Answer: (D)

[EN] T(n) = T(n/2) + O(n) for finding mid via slow/fast pointers solves to O(n) time overall.

[HI] हर चरण में मध्य (Middle) नोड तक पहुँचने के लिए O(n) ट्रैवर्सल करना पड़ता है, जिससे कुल समय O(n) हो जाता है।

Q8. Compare while (temp != NULL) vs while (temp->next != NULL) during SLL traversal starting at temp = head:

(SLL ट्रैवर्सल में while (temp != NULL) और while (temp->next != NULL) के बीच सही अंतर क्या है?)

(A) temp != NULL skips the first node while temp->next != NULL prints all nodes

(B) temp != NULL visits every node including the last, whereas temp->next != NULL stops AT the last node (and crashes if head is NULL)

(C) Both loops visit the exact same set of nodes even when head == NULL

(D) temp->next != NULL causes an infinite loop on finite lists

Correct Answer: (B)

[EN] Checking temp->next != NULL exits as soon as temp reaches the tail node (useful for appending), but dereferencing temp->next fails if head == NULL.

[HI] temp != NULL अंतिम नोड सहित सभी को विज़िट करता है, जबकि temp->next != NULL अंतिम नोड पर रुक जाता है (और लिस्ट खाली होने पर क्रैश करता है)।

Q9. What happens if a traversal function advances head directly via while (head != NULL) { printf("%d", head->data); head = head->next; } on the caller's global head pointer?

(यदि ग्लोबल head पॉइंटर पर सीधे while (head != NULL) { ... head = head->next; } चलाकर प्रिंट किया जाए, तो क्या होगा?)

(A) head automatically resets back to the first node when the loop finishes

(B) The list transforms into a circular linked list

(C) Only the last node is deleted cleanly via free()

(D) head becomes NULL after the loop, leaking all nodes in memory and emptying the list reference

Correct Answer: (D)

[EN] Always traverse using a temporary pointer (struct Node *curr = head;) so the original head reference stays intact.

[HI] लूप खत्म होने पर head NULL हो जाएगा और पूरी लिस्ट का पता खो जाने से मेमोरी लीक हो जाएगा; इसलिए हमेशा अस्थायी पॉइंटर curr = head उपयोग करें।

Q10. If a programmer forgets to set tail->next = NULL; after creating the last node with malloc(), what runtime bug occurs during traversal?

(यदि malloc() से अंतिम नोड बनाने के बाद tail->next = NULL सेट करना भूल जाएं, तो ट्रैवर्सल में क्या होगा?)

(A) The list becomes doubly linked

(B) Traversal halts cleanly at the last node automatically

(C) The compiler automatically assigns NULL to every malloc struct field

(D) Traversal follows an uninitialized wild pointer past the end, causing garbage output or a segmentation fault

Correct Answer: (D)

[EN] malloc leaves uninitialized garbage inside struct fields; reading uninitialized next leads to invalid memory access (segfault).

[HI] malloc मेमोरी को शून्य नहीं करता, इसलिए tail->next में कचरा पता रहेगा जिससे ट्रैवर्सल अवैध मेमोरी में जाकर क्रैश हो जाएगा।

Q11. Which limitation applies specifically to a Singly Linked List compared to a Doubly Linked List?

(डबली लिंक्ड लिस्ट (DLL) की तुलना में सिंगली लिंक्ड लिस्ट (SLL) की मुख्य सीमा क्या है?)

(A) Backward traversal from a node to its predecessor is not directly possible without restarting from head

(B) SLL consumes twice as many pointers per node as DLL

(C) SLL requires contiguous memory blocks

(D) SLL cannot grow dynamically at runtime

Correct Answer: (A)

[EN] SLL nodes hold only forward next links, whereas DLL nodes include a prev pointer allowing direct O(1) backward movement.

[HI] SLL में केवल आगे का next पॉइंटर होता है, इसलिए किसी नोड से सीधे पिछले नोड पर नहीं जाया जा सकता।

Q12. Why do Singly Linked Lists suffer more CPU cache misses than Arrays during sequential scans?

(क्रमिक स्कैन के दौरान एरे की तुलना में सिंगली लिंक्ड लिस्ट में CPU कैश मिस (Cache Misses) अधिक क्यों होते हैं?)

(A) Heap-allocated nodes sit at non-contiguous scattered RAM addresses, breaking spatial locality

(B) Linked lists store floating-point pointers that bypass L1 cache

(C) Linked list nodes are always stored in reverse RAM order

(D) Each node requires disk I/O to read its next pointer

Correct Answer: (A)

[EN] Arrays fetch 64-byte cache lines holding multiple consecutive elements, whereas each SLL node jump may hit a completely uncached page.

[HI] हीप पर बने नोड्स मेमोरी में बिखरे रहते हैं (कम Spatial Locality), इसलिए हर अगले नोड पर जाने पर कैश लाइन मिस हो सकती है।

Q13. What is the time complexity to count the total number of nodes in a standard Singly Linked List that stores only a head pointer?

(केवल head पॉइंटर वाली सामान्य सिंगली लिंक्ड लिस्ट में कुल नोड्स की गिनती करने की टाइम कॉम्प्लेक्सिटी क्या है?)

(A) O(1)

(B) O(log n)

(C) O(n^2)

(D) O(n)

Correct Answer: (D)

[EN] Without a cached length counter, counting requires walking every node from head until NULL in O(n) time.

[HI] यदि लंबाई अलग से सेव न की गई हो, तो head से NULL तक हर नोड गिनने में O(n) समय लगता है।

Q14. Which scenario favors choosing a Singly Linked List over a fixed-size Array?

(निम्न में से किस परिस्थिति में फिक्स्ड-साइज एरे की तुलना में सिंगली लिंक्ड लिस्ट चुनना अधिक लाभदायक होता है?)

(A) Minimal memory footprint when storing millions of 1-byte booleans

(B) Frequent insertions and deletions at the front (head) with unpredictable total element count

(C) Frequent O(1) random lookups by index k

(D) Maximizing cache locality for tight numerical matrix loops

Correct Answer: (B)

[EN] SLL provides O(1) front insertion/deletion and dynamic sizing without upfront capacity limits or resizing copies.

[HI] जब शुरुआत में बार-बार इंसर्शन/डिलीशन करना हो और कुल डेटा की संख्या पहले से ज्ञात न हो।

Q15. What does this loop print if head points to 10 -> 20 -> 30 -> NULL? struct Node *p = head; while (p->next != NULL) { printf("%d ", p->data); p = p->next; }

(यदि लिस्ट 10 -> 20 -> 30 -> NULL है, तो लूप while (p->next != NULL) { printf("%d ", p->data); p = p->next; } क्या प्रिंट करेगा?)

(A) 10 20

(B) 10 20 30

(C) 10

(D) 20 30

Correct Answer: (A)

[EN] When p reaches 30, p->next is NULL so the loop exits BEFORE printing 30, outputting only 10 20.

[HI] जब p नोड 30 पर पहुँचता है तो p->next == NULL हो जाने से लूप 30 को प्रिंट किए बिना ही रुक जाता है, अतः आउटपुट 10 20 होगा।

Q16. Which statement is NOT true about Singly Linked Lists?

(सिंगली लिंक्ड लिस्ट के बारे में इनमें से कौन सा कथन असत्य (NOT true) है?)

(A) Singly Linked Lists allow O(1) random access to the i-th node using Base + i * w

(B) Nodes do not require contiguous memory allocation

(C) An empty list is indicated by head == NULL

(D) Each node stores an extra pointer field alongside data

Correct Answer: (A)

[EN] Base + i * w applies only to contiguous arrays; SLLs have scattered nodes requiring O(n) traversal to reach index i.

[HI] Base + i * w केवल क्रमिक एरे पर लागू होता है; सिंगली लिंक्ड लिस्ट में किसी इंडेक्स पर सीधे O(1) में नहीं पहुँचा जा सकता।

Q17. Within Singly Linked List: Node Structure, Head Pointer, Null Reference, which sll component directly maps to: "Pairs data payload with struct Node *next pointer"?

(Singly Linked List: Node Structure, Head Pointer, Null Reference में कौन सा SLL Component सीधे "Pairs data payload with struct Node *next pointer" से संबंधित है?)

(A) Tail NULL Reference

(B) Random Index Access

(C) Self-Referential Struct

(D) Head Pointer

Correct Answer: (C)

[EN] In Singly Linked List: Node Structure, Head Pointer, Null Reference, 'Self-Referential Struct' handles 'Pairs data payload with struct Node *next pointer' (Cannot hold direct struct Node member (infinite size)).

[HI] Singly Linked List: Node Structure, Head Pointer, Null Reference में 'Self-Referential Struct' का कार्य/विवरण 'Pairs data payload with struct Node *next pointer' (Cannot hold direct struct Node member (infinite size)) है।

Q18. Which option accurately describes 'Head Pointer' in Singly Linked List: Node Structure, Head Pointer, Null Reference?

(Singly Linked List: Node Structure, Head Pointer, Null Reference के संदर्भ में 'Head Pointer' की सही विशेषता कौन सी है?)

(A) Sequential O(n) hop-by-hop traversal from head

(B) Stores memory address of first node; NULL if empty

(C) Sentinel stored in last node's next pointer

(D) Pairs data payload with struct Node *next pointer

Correct Answer: (B)

[EN] 'Head Pointer' provides 'Stores memory address of first node; NULL if empty' — key point: Must never be overwritten directly during traversal.

[HI] 'Head Pointer' का मुख्य विवरण 'Stores memory address of first node; NULL if empty' है (Must never be overwritten directly during traversal)।

Q19. In Singly Linked List: Node Structure, Head Pointer, Null Reference, identify the correct parameter for the specification: "Sentinel stored in last node's next pointer".

(Singly Linked List: Node Structure, Head Pointer, Null Reference में "Sentinel stored in last node's next pointer" विवरण किस विकल्प के लिए सही है?)

(A) Self-Referential Struct

(B) Tail NULL Reference

(C) Head Pointer

(D) Random Index Access

Correct Answer: (B)

[EN] 'Tail NULL Reference' corresponds to 'Sentinel stored in last node's next pointer' (Terminates traversal loops cleanly without segfaults).

[HI] 'Tail NULL Reference' का संबंध 'Sentinel stored in last node's next pointer' (Terminates traversal loops cleanly without segfaults) से है।

Q20. Considering Singly Linked List: Node Structure, Head Pointer, Null Reference, what key behavior defines 'Random Index Access'?

(Singly Linked List: Node Structure, Head Pointer, Null Reference में 'Random Index Access' की मुख्य भूमिका या मान क्या है?)

(A) Sentinel stored in last node's next pointer

(B) Pairs data payload with struct Node *next pointer

(C) Sequential O(n) hop-by-hop traversal from head

(D) Stores memory address of first node; NULL if empty

Correct Answer: (C)

[EN] 'Random Index Access' represents 'Sequential O(n) hop-by-hop traversal from head' (Extra pointer per node reduces CPU cache locality).

[HI] 'Random Index Access' का अर्थ/मान 'Sequential O(n) hop-by-hop traversal from head' है (Extra pointer per node reduces CPU cache locality)।

Singly Linked List: Node Structure, Head Pointer, Null Reference — Exam FAQs

Q1: Why can struct Node contain struct Node *next but NOT struct Node next?

struct Node के अंदर struct Node *next तो वैध है लेकिन struct Node next अवैध क्यों है?

[EN] Embedding struct Node by value forces the compiler to calculate infinite recursive size. A pointer struct Node *next always has a fixed size (4 or 8 bytes) known to the compiler regardless of what it points to.

[HI] पूरा struct Node अंदर रखने पर उसका आकार अनंत हो जाता है। इसके विपरीत पॉइंटर struct Node *next का आकार हमेशा निश्चित (4 या 8 बाइट्स) होता है, इसलिए कंपाइलर उसे आसानी से आवंटित कर पाता है।

Q2: What is the difference between p == NULL and p->next == NULL in linked list code?

लिंक्ड लिस्ट कोड में p == NULL और p->next == NULL के बीच क्या अंतर है?

[EN] p == NULL checks whether p itself points nowhere (empty list or past the tail), whereas p->next == NULL checks whether the valid node p is the final node in the list (unsafe to run if p itself is NULL!).

[HI] p == NULL जाँचता है कि पॉइंटर स्वयं खाली है (अर्थात लिस्ट खाली या समाप्त), जबकि p->next == NULL जाँचता है कि मौजूदा नोड p अंतिम नोड है (यदि p ही NULL हो तो p->next क्रैश कर देगा)।

Q3: How much extra memory overhead does a Singly Linked List add compared to an int array?

int एरे की तुलना में सिंगली लिंक्ड लिस्ट में कितनी अतिरिक्त मेमोरी खर्च होती है?

[EN] Each node adds one pointer field (4 bytes on 32-bit, 8 bytes on 64-bit—plus potential struct alignment padding, often making a 4-byte int node occupy 16 bytes total on 64-bit systems) plus allocator metadata.

[HI] प्रत्येक नोड में एक पॉइंटर (32-बिट पर 4 बाइट, 64-बिट पर 8 बाइट) व संभावित पैडिंग अतिरिक्त लगती है, जिससे 64-बिट सिस्टम पर 4-बाइट int का एक नोड अक्सर 16 बाइट्स तक घेर सकता है।

Related Posts

  • Loading related posts...

Post a Comment

Search Topic Notes & 20 MCQs (Hindi / English)