#3.1 Java Collections Framework in Hindi | LinkedList Introduction
#LinkedList – Collections Framework : Similar to arrays in
Java, LinkedList is a linear data structure. However
LinkedList elements are not stored in contiguous locations
like arrays, they are linked with each other using pointers.
Each element of the LinkedList has the reference(address/pointer) to the next element of the LinkedList. Each element in the LinkedList is called the Node. Each Node of the LinkedList contains two items:
1) Content of the element.
2) Pointer/Address/Reference to the Next Node in the LinkedList.
Note:-
Head of the LinkedList only contains the Address of the First element of the List.
The Last element of the LinkedList contains null in the pointer part of the node because it is the end of the List so it doesn’t point to anything.
The diagram which is shown above represents a singly linked list. There is another complex type variation of LinkedList which is called doubly linked list, node of a doubly linked list contains three parts:-
1. Pointer to the previous node of the linked list.
2. Content of the element.
3. Pointer to the next node of the linked list.
Why LinkedList is better than Array?
You must be aware of the arrays which is also a linear data structure but arrays have certain limitations such as :-
1) Size of the array is fixed which is decided when we create an array so it is hard to predict the number of elements in advance, if the declared size fall short then we cannot increase the size of an array and if we declare a large size array and do not need to store that many elements then it is a waste of memory.
2) Array elements need contiguous memory locations to store their values.
These limitations are handled in the Linked List by providing following features:
1. Linked list allows dynamic memory allocation, which means memory allocation is done at the run time by the compiler and we do not need to mention the size of the list during linked list declaration.
2. Linked list elements don’t need contiguous memory locations because elements are linked with each other using the reference part of the node that contains the address of the next node of the list.
the next node of the list.
#programminggalaxy #linkedlist #linkedlistinjava
Видео #3.1 Java Collections Framework in Hindi | LinkedList Introduction автора Java Алгоритм
Видео #3.1 Java Collections Framework in Hindi | LinkedList Introduction автора Java Алгоритм
Информация
5 декабря 2023 г. 8:02:40
00:09:51
Похожие видео