"Just Think" Agar aapko 100 names store karne hai to aap konsa data structure use karoge probably Array ko because array ko sirf declare karna hai aur wo 100 names ko store karna hai, "Now Think" agar aapko 200 names ko store karna ho to ? again new array banana padega of size 200 aur phir elements ko store karna padega aur agar sirf 50 elements ko hi store karne ho to ? lekin array to 100 size ka hai to 50 elements ki memory space waste hogi. So the point is Array's static hote hai inka size ham bas ek baar hi declare kar sakte hai aur wo size kabhi bhi runtime par change nhi kar sakte isi limitation ko overcome karti hai Linked List.
Linked List
Linked List ek Linear Data Structure hota hai, jisme elements (Nodes) ek dusre se linked hote hai aur ek chain form karte hai.
- Linked List ek bahut hi commonly used data structure hai, nodes(ek unit jisme data aur next node ka address store hota hai) ke group se chain form karti hai.
- Har ek node mein apna data aur next node ka address store hota hai, jisse chain form hoti hai.
- Linked List ka used advance data structure implement karne ke liye bhi use hota hai, like tree and graph.
Advantages of Linked Lists
- Linked List ka nature dynamic hota hai.
- Insertion and Deletion operations easy hote hai.
- Stack and Queues ko easily execute kar sakte hai (Stack and Queue are next topic of this series).
Disadvantages of Linked Lists
- Linked List mein extra space required hoti hai kioki address bhi store karna padta hai.
- Koi bhi element randomly access nhi kar sakte har element sequentially hi access karna padta hai.
- Reverse traversal thoda difficult hota hai, compare to array.
Application of Linked List
- Linked Lists ka use other data structures ko implement karne ke liye hota hai, eg stack, queue, and graph etc.
- Linked Lists se ham polynomials ko efficiently represent kar sakte hai, har ek node ek coefficient aur exponent ko store kar sakte hai.
- Mostly file systems ko implement karne ke liye linked list ka use karte hai.
Types of Linked List
Mainly three types ki linked lists hoti hai. Other linked lists inhi three linked lists ke variations hote hai.
- Singly Linked List
- Doubly Linked List
- Circular Linked List
- Doubly Circular Linked List (Combination of Doubly and Circular)
Singly Linked List
Singly linked list mein nodes hote hai jisme two fields hoti hai one for data aur second for address of next node, isme nodes ka sequence hota hai.
Ham singly linked list par insertion, deletion, and traversal operations bhi perform kar sakte hai.
Doubly Linked List
Doubly linked list mein three fields hoti hai data, address of next node, and address of previous node.
Circular Linked List
Circular linked list ek normal singly linked list hoti hai, lekin normal linked list mein last node null ko point karta hai, isme aisa nhi hota hai, balki last node first node ko hi point karta hai.
Doubly Circular Linked List
Linked list ka ye variation ek combination hota hai doubly linked list and circular linked list ka. Isme har node previous node aur next node ke address ko hold karta aur last node linked list ke first node ke address ko store karta hai instead of null.
Comments