CIRCULAR 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 in previous session we have seen how to create a circular link list and how to display the notes officer Clem contest in today's session we'll go with and also we have seen the insertion so how to insert an element at the beginning position at the ending position and and this is fied position so in the today's session we'll go with the other operation that is deletion operation so how to delete an element from the circular linked list from the beginning position and from the ending position and from the specified position all the three cases will be covered into decision right let us start the session right circularly finished let us take an example and we will start the session so let us take the four elements there were four modes right so you know that every node is having two fields one is data and Berman is that pointer field so let it be 10 20 30 and 40 the address of ten is thousand and no software these two thumbs in address of 30 is three thumbs attic and there's of 40 is 4,000 so the first node holds the address of the second node that is 2,000 the second node will holds the address of third node that is three thumbs in third node will enters and bin holds the address of fourth row that is 4,000 and it is a circular link release the last Lord holds the address of the first node wrappings how is it so there will be a link from last move all right and we know that the first node will be head and the last node will be a so we have discussed this deletion operation in the same single linked list that relation means just we we are disconnecting the link between one load and under that no and if you want to deallocate the memory we can use the flip function so that particular lower if you apply this particular load to the free function automatically the memory will be de-allocated okay so first thing we have to discount the link how to disconnect a link we have seen that just remove the address which is presented in the address field and replace with the null so that automatically the link will be disconnected we'll go with the first first case so we are seeing this deletion deletion operation right so first one deleting the element from the beginning position that means if you want to delete a 10 so 10 should be deleted then should be deleted see so I'm drawing the output so that we will write the steps so ten twenty thirty forty three thousand four thousand thousand so if you delete this element if you delete this element the head must be moved to 20 and the address of the last node in the address field of the last node should contain the end of second one right let's let us take out head n okay right so you should not change the head so first I will do assignment to temporary variable right well just go ahead here due to temporary variable I am now moving the head from first position to the next position because the head should be in the next position because we are deleting the first payment so head is equal to head off next so automatically after to you during the statement the head will be moved from here to here right okay then see this stay I mean the address field of a should match with the address of the first element here the first element analysis mm so a off next so what is the K of next this field is equal to head so after 2 din the statement L of next this will be replaced with conclusion so here also the connection is disconnected and here connection is established now one more thing we have to rule what is then this link should be disconnected this link this linkage should be disconnected so we have we have a saying hello to temp so here there will be simply we have right tempo flexed f of X is equal to null so of automatically here it removes the mm and it places them null that implies it disconnects them link between this node to the next one right so the output is this one first segment is 20 30 40 and 40 is mapping with the first element so hopefully understood so if you want to be allocate the memory already get if you apply the three function to the temp automatically this this memory will be de-allocated right so how do you resolve this so first we are changing the head and then we are establishing the link right and it is equal to hit I mean we are establishing the link from tail to N and then we have placing the mouse to the first lower that means we are disconnecting the first more so this is all about the in deletion of an element from the beginning position right hope you soon now will go with the second thing that is deletion from the ending deletion from the ending ya see ya there is a limb from now ii deviation from end deleting an element from and so here we'll have to do it this then or forty so that we have to remove the tail to the left side and thirty will be the last element and the last element enters should be the head should be assigned to head okay right now let us see so just we will assign headed to ten we will assign headed to temp so automatically okay we need to move the temp till 30 we need to move the temp t30 so that means simply we can find the internal statement by temp of next not equal to take so it will move until the tempo of next to not equal to a right so temp of next not equal to 10 so 10 is 4000 temp of next means 2000 right so every iteration we have to move the temp so moving the templates simply temp is equal to temp of next right let us change this one first improve next 2000 not equal to a foreclosure - so temporal type of next now temp of next means so after the first iteration that can we'll be moving towards this one so here it is step now tempo flexed 3,000 not equal to 4000 - temp is equal to temp of next the temp will be moved from here to here right next 4,000 not equal to 4000 false so it comes out from the loop okay it comes up from the loop so after completion of these iterations the temp is pointing towards the last but one and it mate okay so hope you understood this one now see what what you have to do here we have to disconnect this one right we hope to dis commit this a so simply replace this thousand with love so what is this position tale of next is equal to love automatically this thousand will be removed and null will be a same here that means connection is disconnected here connection is disconnected then now what we have here we have to disconnect this connection between the last patrol elevated in the last element and also here instead of 4000 we have to place mm right for that we know that what is this position improv next temp of next tempo flex means 4000 is equal to head em of next is equal to and automatically here it will remove the four thousand and housing so it was disconnected it was disconnected here and a connection is established from here to here right now take is equal to them because the last statement will be tame so here we are saying ale here just remove here we can remove that one okay so this is a small thing hope you understood so how to delete an element at the ending position how to delete an element from the ending position so far here so first we have to travel the temp from first element to last but one element so then we have to disconnect the last element right so there is a link between the last element is in first element because it is a circular Lincoln so we first we have to disconnect the last element that link between the last element in the first segment and then we have to disturb the link between the last but one element to the last segment and we have to move the tail right so this is a small code watch it for deletion at the L position now we will go with the third one that is how to delete an element from the specified position hey this is the third case so how to delete an element from the specified position so here we have to take the input as a position so from a we have to delete them so the first statement is scanf % HD cameras in position so first we have to find the position where we want to delete the element so then we have to move the temporary value because we are not moving the head so just will assign the head to temp value right so now we have to change the head position or temp position from starting point to the position minus one so this is a code which we have seen in the signaling released simply do the iterations I is equal to zero I less then position minus 1 I plus less so simply we have to move that one so temp is equal to temp of next so here see so initially this is the temp because here we are sending temperatures equal to 10 that he'll be position is equal to 2 position is equal to 2 so in the first iteration I is equal to 0 position sorry ID is less than position minus 1 2 minus 1 1 so true automatically we'll have to change the temporal so M is equal to temp of next so mm so this temp will be moved to 2000 hope you understood this one right so temp is equal to 2000 now the second iteration I plus place so I is equal to 1 so 1 less than 1 false so just stop the iterations just to stop the iterations what we have to do here so we have to discount the second image that means this event so this element should be disconnected so we have to discourage the link between temp and the next one so here what you have there in the signaling village just we have placing the address off sorry it is not not just we are placing just we are placing the address of the next changement we are just skipping the middle element the position in good we are skipping the positioned element right so we are just disconnecting the link right so temper of rest is equal to that means disposition temper of next all flexed so temp of next means C 3000 and temp of next stop next that means photos so 3000 will be moved with photos automatically this link is disconnected and see it is placing here itself okay it is placing head itself right so what we understood this one so just we have blessing the link we're just skipping the leap okay so tempo of next amp of next means this disposition is equal to improve next that makes 3000 or flex for that piece of 4000 so 4000 will be moved in the address position of M automatically that particular 3000 element will be disconnected from the link reduced okay so hope you understood this one right right so sympathy so there is no change in deletion of an element from the specified position so the same code which we have used in the single link released the same thing we are using so there is a slight difference in beginning position deletion of an elevation element from beginning position and ending position right so let us stop here so hope you understood my session if you really understood my session like my sessions share my sessions with your friends and if you are having any doubts regarding this session feel free to post your thoughts in the comment section so that I will definitely try to clarify all your notes and don't forget to subscribe to our channel keep following our channel thanks for watching thank you very much
Info
Channel: Sundeep Saradhi Kanthety
Views: 25,721
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, circular linked list
Id: DHyOfyqrhTw
Channel Id: undefined
Length: 20min 8sec (1208 seconds)
Published: Sun May 26 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.