Lined List
with a very good example i will show what is linked list and why would you like to use it. The name of linked list is the name of a linked list , if you 're listening for the very first time and it is possible that you 've read it before and did n't understand that i will start with and example to explain this thing and the example will be of a hospital. In every hospital each single bed was utilized utilized utilized them so this is linked list. The advantage we got here is that we could n't get all the beds at the same place. The size of our array can be so large that we do n't know2 today these are 7 tomorrow these may be 7 lakhs even then if we want to allocate memory if the array of 7 expands or if the capacity of array is low then it will be a problem. In linked list it has a node which has a space for data one is for pointer to next and another one for pointer. This too will run like this and point to the next node so here as you remember the example of the hospital how did I gave the analogy that i just gave an example to explain. To extend this list is very easy to extend this is not easy and sometimes impossible too. LinkedList is just like a chain it is a chain with hooks. Inserting and deletion in linked list is so easy as much as is to interconnect two links. If you would have created an array you do n't get the luxury to remove this how will you remove this element this is contiguous memory location you have to move it only or else they wont be there. for no use array has its own benefit and this is advantageous there this one is not and where this is not advantageous there is not. Let's see where which to use and which one will give you advantage and when assume that if you want to access the elements like this 4 element 8th or 9th element so you can access in constant time do you have this pointer assume this pointer how much you have to join to get the access the ptr. The address is 280 so in this 280 is there and is pointing that point does n't mean that it is done by a finger it means in this the address is kept stored i will do and show you by coding it. The drawbacks of array are the linklist shines over here have written the thing completely short crisp and to the point are not lengthy notes at all which means short crisp. In linked list the memory and capacity are the same in linked list you can join the nodes and remove nodes from the mid does n't matter in array. In array and linked list we have seen that the memory is the same. In linked lists elements are there in non contiguous memory location if it is 0 then it can be 2000 or 4000 and then the next node can be again 40 anywhere.
Written for
- Institution
- MAKAUT University
- Course
- Data Structure and Algorithm
Document information
- Uploaded on
- March 19, 2023
- Number of pages
- 18
- Written in
- 2022/2023
- Type
- Class notes
- Professor(s)
- Nil
- Contains
- All classes
Subjects
-
linked list
-
dsa