LINKED LIST (DELETION FROM BEGINNING,ENDING AND SPECIFIED POSITION) - DATA STRUCTURES

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello friends welcome back to our channel so in the previous session we have seen the inception how to insert an element to the linked list and how to insert the element at the ending beginning and the specific location now in this session we will see how to delete an element from the linkedlist so we'll consider one existing linked list some with five nodes and from the five nodes we will see the deletion operation so how an element is deleted from the beginning how the element is deleted from the ending position and how the element is deleted from the specified position right now let us see that so linking list so in the klinke list we are seeing the deletion operation so first let us see the link released existing link reduced so let us consider five robots let it be these are the five nodes some 10 20 30 40 50 the memory of this thousand 2000 3000 4000 and 5000 so we know that linking Leisha means two frames will be there one is the data filter where is the address of the next node so here the enters of 20 will be stood here the address of 30 will be stood here the address of 40 will be stored and here of 52 this tool and here it is a la statement so the address will be none so this one indicates the last element of the list now consider this as head and this as a right now first delete at beginning delete an element at the beginning so what is the output first we will see now put them we can write the code according to the out so we know that if you do the event note 10 the first code will be C so only four words will be available and the first node will be 20 30 40 and 50 and here the memory location is proposing ten thousand four thousand and the Pythons how here it will be it's a four thousand safai chosen and it's not now so this is the output that means if you do it in the beginning ignore this L will be deleted right so the first element will be so this is the head and this is the thing there is no change on time there is a change in head so here we need not read any value because here we were not inserting but we are deleting the element so in the little list just deleting it and element so delete means simply disconnect the link disconnect that live right so how to disconnect the link so here we said that this is a link between one more another so how to disconnect this link means placing null at address position I just feel not a position address field right so by placing another address three address 3 that node will be get discounted because we said that the number of elements will be occupying in friend locations and we are establishing a link between one load in Harvard mode by placing the address of floor in the present so here the road is 20 and the address told is the address of 30 that means the second day we maintain cursor will be stored in first note address field so here if you place null head there it is free automatically the link will be disconnected so here if you observe here if you place love here then automatically there will be no link between the first statement 28 NP because so it points to the address of the location I address of them no the second node so here the address is love so it doesn't point to the another room so automatically this will be the single node syncing them so this is a linkedlist so in such a way then we have to discount the link like this we are deleting the element see you see one by one step now hope you understand this one right disconnecting the link that means play signal at address field so whatever the element we are we want to do it we have to place the null in that particular element so here if you want to delete the 10 in the place of mm we have to place null automatically this load will be disconnected from the lincolnís so in order to place null see we have to move the head to second element because after deleting this node the head will be on element to node 2 so see this remember we need not modify the head right so we can take for temporary variable and we can assign the head to the temporary variable so temporary is equal to head now what we have to do see MP is equal to head so here the temp is also here itself is pointing here now the temp of next sorry head is equal to hand off next so after executing this statement head will be more to here head is equal to head of next next now we have to place my at the address trailer so M of next is equal to automatically here the mm will be replaced with no right so this connection will be disconnected the connection will be disconnected so the output will be this one this one is stopped and hope you are screwed so here we have to take care about the execution of the statements first we have a plate Jeju this statement and then the second statement but we need not we should not change the order of statement because see I will show you that temp is equal to head so we are setting the term so if you place temp of next is equal to null and head is equal to head of next see the same MO the same but these four clear statements I have been extracting right so first I am initializing null and then I am moving the head so if you write this one you'll see two thousand and this is the head so if you execute this one first M of X is equal to null so obviously temp of next is equal to right next we have to move the head head is equal to head of next so here head of next there is no address so wave the head should be moved so it doesn't know where to be moved because the address is we are assigning null so here the we should drop we can't move the head right so that's why there's a main project here we can't move the head after placing the lung right so it's a first step we have placing the mail at the exposition so automatically the link has been disconnected so we can't move the head to the second element because there is no link from the first element of second element that's why we have to first move the head and then we have to place another so we have to take care about the link so first we have to move and then we have to disconnect the no right so this is the wrong step right this is the right thing so this is the simple logic if you want to delete an event at the beginning position now so hope you understood this one right next we will see the second thing Hey here it is it a and this is a this is the header minute at and now see if you observe here sorry see if you observe here in the second case we are deleting an element at the end so here we are deleting the 50 the number 50 so that the tail should be moved to 40 and the address of industrial of this 40 mode should be null because null indicates the last element right so now let us see this one here also we should not change their head value so that's why we're taking temporary as a head right we are taking temporary as head next so we have to move T committed so why tip off next not equal to a so it doesn t not equal to 10 mins here the temp will be here so we have to travel temp is equal to temp off next so just we have we are writing somewhat right of statements right so this is a try to escape and means until the temp of next is equal to tail the M will be moving towards it's alright so temp of Lynch temp of minutes f of X is null so the temporary will be here itself right here sorry here that F will be here right so now now simply place the temp here so it ends on now please temp of next is equal to love audibility here instead of riding 5000 we are just replacing it as null if you place null automatically the link has been disconnected right the link has been disconnected now see something they is equal to and now initialize I mean I have to change them okay so here it will be just move here we're just assigning right so in the previous session I mean in the previous case we are moving ahead we have to move the head right so here the last element so we are just assigning the temp to 10 okay so this is the code for creating an element at the end position hope you understood here right so this is that output we got down so just we have to disconnect the link so if you disconnect the link automatically the element is deleted in our perspective the node so placing the null value at the address field of the particular node the previous one now the third case specified position specific position deleted specific position some frozen right no specific position so here we required a position so where it should be inserted I mean deleted which I thought should be D so here we have to read the positions can have % ng T number Z position so until that position let it be PU oh yes is equal to 2 right 2 0 1 2 that means this is we need to delete that part let n me we need to delete that part really now so for that we have to move the head from 0th position to position minus 1 so 4 so the things simply see here in this field we have to place the address of 40 we have to place the address of 40 and here we have to place ma or we can live a very simple move that one we can simply endeavor so here instead of 3,000 we have to link this load with the 40th mode now from I is equal to 0 I less then position minus 1 I plus plus so until that until this condition fails we have to move the temporary level so before we have to initialize n to M so we need not change the head value M of next person so sorry so temp is equal to temp of next automatically until the temp reaches the position minus 1 it will move so no the temp will be in this position right love see tip of next M for next here instead of 3000 we have to place here the photos address off 40 so in order to get this one simply we can write improv next so temp of next wins 3000 that things a 4000 will be there and sorry temp of next week's 3000 end next temp of next off next that means temp of next three thousand off next four palsy right so this is a referential point divided so temper flexed wins three thousand off next that we see and the position of 3,000 work Sandra's photos here if you put data automatically we can get 30 oh sorry sorry so temper flexed means three thousand three thousand of data means 30 here instead of Delta we are placing next so temp of next three thousand of next so in the three thousand what is the occurs four thousand so four thousand will be placed it here F of next okay don't get confused so just we are linking right we are traveling forward so if you want to place finals in to can simply write temp off like stuff next stuff next if you want to print the data directly we can print the data here if you print the data we can get the value here we are printing the address we are setting the interest so temp of flex-cufs next amp of next is 3000 3000 in the 3000 position what is the next four position so four thousand will be a safe here in the place of Thomson right so simple let's see so we need not so if you place this one this is null this is mm this is four thousand this is five thousand it is five thousand this is four thousand this is to see after tilting this core we'll get this one because we are placing 3,000 to 4,000 so obviously the link will be disconnected here and the link will be kind of connected to here so this load will be left saying there's naught will be left signal so after executing this core and live so here instead of three thousand we are placing four thousand so automatically the link is established between 20 and 40 so this node this node will be single so in our perception it is admitted so there is no element I mean there is no connection before this element with our regular statements so that's why we can simply ignore so the output will be this one if you want to delete an element from the specific position believe it from specific position simply we can vary the position we can travel this temp until the position minus one and then we can place the next node address into the present mode that means temp of next is equal to temp of next of fixed so 5,000 will be assigned here some 4000 bps in here and so there will be a link between this 30 load will be disconnected from 20 and 40 right so this is about the tradition operation so hope you have understood this session so if you are having any doubts regarding this insertion and deletion feel free to post your doubts in the comment section that I will definitely try to clarify all your goods and definitely I will post the link of creation and display and insertion in the videos in the description section so that you can refer that for a better understanding right so once we complete all these things I will make one more video for implementing all these operations insertion creation the display deletion right in the next section we will see the reverse and count so how to reverse the link release and how to count the number of loads presented in the linked list right so we'll stop here so in this session we have seen the deletion operation how to delete an element from the linked list at the beginning from the deleting an element from the linked list from ending and from the specific position right so if you really understood my sessions like my sessions share my sessions with your friends and don't forget to subscribe to our channel thanks for watching thank you very much
Info
Channel: Sundeep Saradhi Kanthety
Views: 55,050
Rating: undefined out of 5
Keywords: linked lists, stacks, queues, trees, graphs, searching, sorting, insertion, deletion, operations on data structures, primitive, non primitive, linear, non linear, binary trees, binary search trees, LINKED LIST, NODES, ADDRESS, BEGINNING, ENDING, SPECIFIED POSITION, ESTABLISH LINK, SINGLE LINKED LIST, CREATE, DISPLAY, INSERTION, DELETION, DISCONNECT LINK
Id: RyWuK9no5s8
Channel Id: undefined
Length: 21min 31sec (1291 seconds)
Published: Wed May 15 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.