title
Linked List in Java 2
description
Get the Code: http://goo.gl/DZ3al
In the last video, I showed you how to create Linked Lists and how to manipulate them.
In this tutorial, I will cover Double Ended Linked Lists which have a reference to the first and last link. I cover how a Doubly Linked List allows you to go backwards and forwards in a list. Then we take a look at Iterators and how they work.
detail
{'title': 'Linked List in Java 2', 'heatmap': [{'end': 346.907, 'start': 309.97, 'weight': 0.787}], 'summary': 'Tutorial on java algorithms covers double-ended linked lists, iterators, and practical implementation, emphasizing 100% code implementation and creation of a linked list filled with neighbors in a neighborhood.', 'chapters': [{'end': 93.167, 'segs': [{'end': 26.546, 'src': 'embed', 'start': 0.109, 'weight': 0, 'content': [{'end': 3.811, 'text': 'Well hello internet and welcome to part 5 of my Java algorithms tutorial.', 'start': 0.109, 'duration': 3.702}, {'end': 7.894, 'text': "Today we're going to cover again linked lists inside of Java.", 'start': 4.032, 'duration': 3.862}, {'end': 11.076, 'text': "If you didn't watch part 1, you should definitely watch it, otherwise you may be confused.", 'start': 8.013, 'duration': 3.063}, {'end': 15.239, 'text': 'and of course, I have a link to a playlist of all the tutorials in the upper right hand corner.', 'start': 11.076, 'duration': 4.163}, {'end': 21.162, 'text': "In today's tutorial we're going to cover double ended linked lists, doubly linked lists, iterators and a whole bunch more,", 'start': 15.399, 'duration': 5.763}, {'end': 25.445, 'text': 'and because you guys have requested it, this tutorial is going to be almost nothing but 100% code.', 'start': 21.162, 'duration': 4.283}, {'end': 26.546, 'text': "So let's get into it.", 'start': 25.485, 'duration': 1.061}], 'summary': 'Java algorithms tutorial part 5 covers double ended linked lists, iterators, and 100% code.', 'duration': 26.437, 'max_score': 0.109, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk109.jpg'}, {'end': 80.673, 'src': 'embed', 'start': 54.89, 'weight': 2, 'content': [{'end': 62.337, 'text': "And what the heck? Because I am going to get into doubly linked lists, I'm also going to put a link to the previous neighbor in the linked list.", 'start': 54.89, 'duration': 7.447}, {'end': 64.858, 'text': "I'll create myself a constructor here.", 'start': 62.737, 'duration': 2.121}, {'end': 70.364, 'text': "And this is just simply going to get the homeowner's name passed to it and the house number.", 'start': 65.319, 'duration': 5.045}, {'end': 72.386, 'text': "And we're going to save those inside of there.", 'start': 70.664, 'duration': 1.722}, {'end': 76.79, 'text': "Then just to keep this very simple, I'm also going to create a display.", 'start': 72.606, 'duration': 4.184}, {'end': 80.673, 'text': "And it's just going to output information in regards to that information that's passed in there.", 'start': 76.83, 'duration': 3.843}], 'summary': "Creating a doubly linked list with a previous neighbor link, using a constructor to store homeowner's name and house number, and a display function for outputting information.", 'duration': 25.783, 'max_score': 54.89, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk54890.jpg'}], 'start': 0.109, 'title': 'Java algorithms tutorial part 5', 'summary': 'Covers double ended linked lists, doubly linked lists, iterators, and more, with an emphasis on 100% code implementation and creating a linked list filled with neighbors in a neighborhood.', 'chapters': [{'end': 93.167, 'start': 0.109, 'title': 'Java algorithms tutorial part 5', 'summary': 'Covers double ended linked lists, doubly linked lists, iterators, and more, along with an emphasis on 100% code implementation, and creating a linked list filled with neighbors in a neighborhood.', 'duration': 93.058, 'highlights': ['The tutorial covers double ended linked lists, doubly linked lists, iterators, and more. The tutorial will cover various topics including double ended linked lists, doubly linked lists, and iterators.', 'The tutorial will be almost 100% code. The tutorial will emphasize almost 100% code implementation.', 'Creating a linked list filled with neighbors in a neighborhood. The focus will be on creating a linked list filled with neighbors in a neighborhood.']}], 'duration': 93.058, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk109.jpg', 'highlights': ['The tutorial covers double ended linked lists, doubly linked lists, iterators, and more.', 'The tutorial will be almost 100% code.', 'Creating a linked list filled with neighbors in a neighborhood.']}, {'end': 430.954, 'segs': [{'end': 139.594, 'src': 'embed', 'start': 111.522, 'weight': 0, 'content': [{'end': 115.024, 'text': 'That is what makes it different than the linked list we talked about previously.', 'start': 111.522, 'duration': 3.502}, {'end': 120.926, 'text': 'But, of course, with any changes that we are going to be making, we are going to have to change our methods.', 'start': 115.144, 'duration': 5.782}, {'end': 124.808, 'text': "So we're going to have the first link and the last link stored inside of it.", 'start': 121.186, 'duration': 3.622}, {'end': 127.849, 'text': 'And then we get to insert in first position.', 'start': 124.988, 'duration': 2.861}, {'end': 131.05, 'text': "And I'm going to jump over to a presentation to explain exactly how that works.", 'start': 127.869, 'duration': 3.181}, {'end': 139.594, 'text': 'Okay, so if I want to insert a new link or a new neighbor into our neighborhood and I want to put it in the very first position in the linked list,', 'start': 131.331, 'duration': 8.263}], 'summary': 'Introducing changes to linked list methods, including insertion in the first position.', 'duration': 28.072, 'max_score': 111.522, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk111522.jpg'}, {'end': 180.036, 'src': 'embed', 'start': 153.36, 'weight': 3, 'content': [{'end': 158.583, 'text': "save that now, because we're dealing with a double-ended linked list to first link.", 'start': 153.36, 'duration': 5.223}, {'end': 164.887, 'text': 'previous and first link, of course, is going to be a reference to just another neighbor in the neighborhood.', 'start': 158.583, 'duration': 6.304}, {'end': 166.547, 'text': "so that's the first thing we're going to do,", 'start': 164.887, 'duration': 1.66}, {'end': 176.313, 'text': 'and then the only other thing we need to do is go and set the value for next for our new member inside of the neighborhood to whatever the object is,', 'start': 166.547, 'duration': 9.766}, {'end': 180.036, 'text': 'that is assigned to first link in our double ended link list.', 'start': 176.313, 'duration': 3.723}], 'summary': 'Creating a double-ended linked list with references to neighbors and setting the value for the next member.', 'duration': 26.676, 'max_score': 153.36, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk153360.jpg'}, {'end': 233.555, 'src': 'embed', 'start': 197.351, 'weight': 1, 'content': [{'end': 201.269, 'text': "So we're going to go if is empty, which I'm going to create here in a second.", 'start': 197.351, 'duration': 3.918}, {'end': 205.111, 'text': "So if our list is currently empty, it's going to be very easy to set this up.", 'start': 201.469, 'duration': 3.642}, {'end': 213.576, 'text': "I'm just going to go last link for our double-ended linked list is going to be equal to the new link that was passed in here, that was just created.", 'start': 205.191, 'duration': 8.385}, {'end': 219.619, 'text': "And then, after I'm done with that, I just need to assign the reference to the previous first link, just like I previously showed you,", 'start': 213.736, 'duration': 5.883}, {'end': 222.38, 'text': 'and assign the new link to first link inside the linked list.', 'start': 219.619, 'duration': 2.761}, {'end': 223, 'text': "So I'm going to go.", 'start': 222.44, 'duration': 0.56}, {'end': 230.974, 'text': 'the new link next is now going to have the value for whatever first link is inside of our linked list.', 'start': 223, 'duration': 7.974}, {'end': 233.555, 'text': 'set that as new link and then we just need to go.', 'start': 230.974, 'duration': 2.581}], 'summary': 'Setting up a new link in an empty list.', 'duration': 36.204, 'max_score': 197.351, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk197351.jpg'}, {'end': 346.907, 'src': 'heatmap', 'start': 309.97, 'weight': 0.787, 'content': [{'end': 316.774, 'text': "So here we're going to go last link next is going to be equal to the new link that we're going to be adding.", 'start': 309.97, 'duration': 6.804}, {'end': 324.458, 'text': 'And then new link, just like I said previously, previous is going to be equal to whatever the previous last link was.', 'start': 316.974, 'duration': 7.484}, {'end': 325.799, 'text': 'So pretty simple there.', 'start': 324.739, 'duration': 1.06}, {'end': 329.201, 'text': "Then we're going to close that else statement and assign last link.", 'start': 325.819, 'duration': 3.382}, {'end': 332.104, 'text': 'equal to the new link that we just created.', 'start': 329.682, 'duration': 2.422}, {'end': 334.086, 'text': "And that's all we needed to do there.", 'start': 332.124, 'duration': 1.962}, {'end': 337.089, 'text': "Now, since I'm using isEmpty a whole bunch of times here,", 'start': 334.286, 'duration': 2.803}, {'end': 343.625, 'text': "I'm going to create it and of course it's going to be simple isEmpty and whatever this is called, It's just going to return,", 'start': 337.089, 'duration': 6.536}, {'end': 346.907, 'text': 'whatever the result of checking if first link is equal to null.', 'start': 343.625, 'duration': 3.282}], 'summary': 'Creating a new link and checking if first link is null.', 'duration': 36.937, 'max_score': 309.97, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk309970.jpg'}, {'end': 395.126, 'src': 'embed', 'start': 366.659, 'weight': 5, 'content': [{'end': 368.961, 'text': 'And then I can just go the linked list.', 'start': 366.659, 'duration': 2.302}, {'end': 373.442, 'text': 'And if I want to insert in first position, no problem.', 'start': 369.441, 'duration': 4.001}, {'end': 374.322, 'text': 'Homeowner name.', 'start': 373.522, 'duration': 0.8}, {'end': 376.062, 'text': "Here I'm going to put Mark Evans.", 'start': 374.502, 'duration': 1.56}, {'end': 379.563, 'text': 'And just to keep it simple, his house number is going to be equal to 7.', 'start': 376.462, 'duration': 3.101}, {'end': 383.184, 'text': "And let's say I want to go in here and throw a couple other random people in.", 'start': 379.563, 'duration': 3.621}, {'end': 384.344, 'text': 'Pierce Polkus.', 'start': 383.444, 'duration': 0.9}, {'end': 386.525, 'text': "And let's set that at 9.", 'start': 384.804, 'duration': 1.721}, {'end': 388.445, 'text': "And what the heck, let's try last.", 'start': 386.525, 'duration': 1.92}, {'end': 389.605, 'text': 'Position as well.', 'start': 388.725, 'duration': 0.88}, {'end': 391.426, 'text': "Here I'm going to put in Doreen Fig.", 'start': 389.765, 'duration': 1.661}, {'end': 393.486, 'text': 'Have her set at 6.', 'start': 391.686, 'duration': 1.8}, {'end': 395.126, 'text': 'And Petunia Dursley.', 'start': 393.486, 'duration': 1.64}], 'summary': 'Creating a linked list with homeowner names and house numbers, including random people like pierce polkus and doreen fig.', 'duration': 28.467, 'max_score': 366.659, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk366659.jpg'}], 'start': 93.687, 'title': 'Double-ended linked list', 'summary': 'Discusses the creation of a double-ended linked list with references to both the first and last link and explains how to insert a new neighbor into the first position. it also covers the process of inserting elements into the list and creating a display method.', 'chapters': [{'end': 197.091, 'start': 93.687, 'title': 'Double ended linked list', 'summary': 'Discusses the creation of a double-ended linked list, which includes a reference to both the first and last link, and explains how to insert a new neighbor into the first position in the linked list.', 'duration': 103.404, 'highlights': ['The double-ended linked list has a reference to both the first and last links, making it different from the previous linked list.', 'Inserting a new neighbor into the first position in the linked list involves setting the next object for the new neighbor and setting its value for next to the object assigned to first link in the double-ended linked list.', 'Creating a new neighbor involves passing the homeowner name and house number into the new neighbor.']}, {'end': 430.954, 'start': 197.351, 'title': 'Inserting into double-ended linked list', 'summary': 'Discusses the process of inserting elements into a double-ended linked list, covering the steps for inserting in the first and last positions, along with creating a display method for the list.', 'duration': 233.603, 'highlights': ['Explaining the process of inserting into the last position of the linked list, involving assigning values and updating references for the new element. N/A', "Detailing the steps for inserting into the first position of the linked list, including handling the scenario when the list is empty and when it's not. N/A", 'Creating a display method for the linked list to easily showcase its elements. N/A']}], 'duration': 337.267, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk93687.jpg', 'highlights': ['The double-ended linked list has a reference to both the first and last links, making it different from the previous linked list.', 'Inserting a new neighbor into the first position involves setting the next object for the new neighbor and setting its value for next to the object assigned to first link in the double-ended linked list.', 'Creating a new neighbor involves passing the homeowner name and house number into the new neighbor.', 'Explaining the process of inserting into the last position of the linked list, involving assigning values and updating references for the new element.', "Detailing the steps for inserting into the first position of the linked list, including handling the scenario when the list is empty and when it's not.", 'Creating a display method for the linked list to easily showcase its elements.']}, {'end': 1151.306, 'segs': [{'end': 555.4, 'src': 'embed', 'start': 528.588, 'weight': 1, 'content': [{'end': 536.354, 'text': 'we can just leave that the way that it is and I can just go into the new link right there and assign to the value of previous,', 'start': 528.588, 'duration': 7.766}, {'end': 539.015, 'text': 'whatever the value for last link is.', 'start': 536.354, 'duration': 2.661}, {'end': 540.775, 'text': 'And that will be able to get a hold of it.', 'start': 539.275, 'duration': 1.5}, {'end': 544.276, 'text': "And now we'll be able to bounce backwards and forwards through our linked list.", 'start': 540.975, 'duration': 3.301}, {'end': 546.957, 'text': 'And that brings us down to insert after a key.', 'start': 544.437, 'duration': 2.52}, {'end': 555.4, 'text': "So let's say we want to be able to insert new neighbors into our neighborhood using a specific key that is passed over and that key is going to be a house number.", 'start': 547.157, 'duration': 8.243}], 'summary': 'Creating linked list to navigate and insert using specific keys.', 'duration': 26.812, 'max_score': 528.588, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk528588.jpg'}, {'end': 795.655, 'src': 'embed', 'start': 766.448, 'weight': 3, 'content': [{'end': 774.61, 'text': "create a current focused neighbor and it's just going to get the value of whatever is first link inside of our linked list.", 'start': 766.448, 'duration': 8.162}, {'end': 780.852, 'text': "And we're going to say while there are still neighbors and the new house number is greater than the current focused house number,", 'start': 774.77, 'duration': 6.082}, {'end': 783.516, 'text': 'we want to continue cycling through these guys.', 'start': 781.112, 'duration': 2.404}, {'end': 785.859, 'text': 'So go current neighbor.', 'start': 783.816, 'duration': 2.043}, {'end': 795.655, 'text': "while it's not equal to null which means that that would be the end of the list and house number continues to be greater than the current neighbor's house number,", 'start': 785.859, 'duration': 9.796}], 'summary': 'Algorithm iterates through linked list to find neighbors with higher house numbers.', 'duration': 29.207, 'max_score': 766.448, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk766448.jpg'}, {'end': 874.482, 'src': 'embed', 'start': 842.207, 'weight': 0, 'content': [{'end': 845.648, 'text': "Then outside of our else statement, we're going to go the new link.", 'start': 842.207, 'duration': 3.441}, {'end': 851.391, 'text': 'next is going to be equal to current neighbor like that, and then we can check this guy out.', 'start': 846.129, 'duration': 5.262}, {'end': 853.172, 'text': "let's go down inside of main.", 'start': 851.391, 'duration': 1.781}, {'end': 854.553, 'text': 'we do a couple things here.', 'start': 853.172, 'duration': 1.381}, {'end': 856.994, 'text': "let's try insert in order.", 'start': 854.553, 'duration': 2.441}, {'end': 864.337, 'text': 'just change this up a little bit like that file, save and execute, and there you can see even though they were entered in a different order four, six,', 'start': 856.994, 'duration': 7.343}, {'end': 867.798, 'text': "seven and nine there are now in order, so that's very useful.", 'start': 864.337, 'duration': 3.461}, {'end': 874.482, 'text': "then let's say that i want to insert myself into this fancy neighborhood after a specific key.", 'start': 867.798, 'duration': 6.684}], 'summary': 'Code modifies and checks order of elements, results in ascending order.', 'duration': 32.275, 'max_score': 842.207, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk842207.jpg'}, {'end': 959.471, 'src': 'embed', 'start': 934.312, 'weight': 2, 'content': [{'end': 944.002, 'text': "then we're just going to go this and then it's going to be the neighbors is going to be whatever was equal to the neighbors that was passed into this guy and then this,", 'start': 934.312, 'duration': 9.69}, {'end': 948.046, 'text': "and then we're just going to go current neighbor is going to be equal to.", 'start': 944.002, 'duration': 4.044}, {'end': 954.449, 'text': "we're going to get the information from the linked list that was passed inside of this and get the value of first link and assign it to that.", 'start': 948.046, 'duration': 6.403}, {'end': 959.471, 'text': "And in essence we're going to be doing the same thing, except we're going to be doing it with previous neighbor.", 'start': 954.729, 'duration': 4.742}], 'summary': 'Updating neighbors in the linked list implementation.', 'duration': 25.159, 'max_score': 934.312, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk934312.jpg'}], 'start': 431.194, 'title': 'Linked list implementation and iteration', 'summary': 'Explains the implementation of a doubly linked list, allowing traversal in both forward and backward directions, and insertion after a specific key, providing detailed steps. it also covers insertion of elements in order in a linked list, implementation of an iterator, and practical examples.', 'chapters': [{'end': 715.266, 'start': 431.194, 'title': 'Doubly linked list implementation', 'summary': 'Explains the implementation of a doubly linked list, allowing traversal in both forward and backward directions, and insertion after a specific key, providing detailed steps for each operation.', 'duration': 284.072, 'highlights': ['The chapter explains the implementation of a doubly linked list, allowing traversal in both forward and backward directions. The doubly linked list facilitates traversal in both forward and backward directions, enhancing the efficiency of data manipulation.', 'The chapter provides detailed steps for insertion after a specific key. The chapter outlines the precise steps for inserting a new neighbor using a specific key, ensuring a structured and organized approach to data insertion.']}, {'end': 1151.306, 'start': 715.446, 'title': 'Linked list insertion and iteration in java', 'summary': 'Explains how to insert elements in order in a linked list and demonstrates the implementation of an iterator for cycling through the list, showcasing practical examples and outcomes such as inserting in order and removing items using an iterator.', 'duration': 435.86, 'highlights': ['The chapter covers the method for inserting elements in order in a linked list, demonstrating the practical outcome of inserting elements in a specific order. The chapter provides a detailed explanation of the process for inserting elements in order in a linked list, showcasing the practical outcome of inserting elements in a specific order such as entering house numbers in order.', 'It explains the implementation of an iterator for cycling through the linked list, providing practical examples and outcomes of using the iterator to display, check, and remove items from the list. The chapter explains the implementation of an iterator for cycling through the linked list, providing practical examples and outcomes of using the iterator to display, check, and remove items from the list.']}], 'duration': 720.112, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/iR5wyCaIayk/pics/iR5wyCaIayk431194.jpg', 'highlights': ['The chapter explains the implementation of a doubly linked list, allowing traversal in both forward and backward directions, enhancing the efficiency of data manipulation.', 'The chapter provides detailed steps for insertion after a specific key, ensuring a structured and organized approach to data insertion.', 'The chapter covers the method for inserting elements in order in a linked list, demonstrating the practical outcome of inserting elements in a specific order.', 'It explains the implementation of an iterator for cycling through the linked list, providing practical examples and outcomes of using the iterator to display, check, and remove items from the list.']}], 'highlights': ['The tutorial covers double ended linked lists, doubly linked lists, iterators, and more.', 'The tutorial will be almost 100% code.', 'Creating a linked list filled with neighbors in a neighborhood.', 'The chapter explains the implementation of a doubly linked list, allowing traversal in both forward and backward directions, enhancing the efficiency of data manipulation.', 'The chapter provides detailed steps for insertion after a specific key, ensuring a structured and organized approach to data insertion.', 'The chapter covers the method for inserting elements in order in a linked list, demonstrating the practical outcome of inserting elements in a specific order.', 'It explains the implementation of an iterator for cycling through the linked list, providing practical examples and outcomes of using the iterator to display, check, and remove items from the list.', 'The double-ended linked list has a reference to both the first and last links, making it different from the previous linked list.', 'Inserting a new neighbor into the first position involves setting the next object for the new neighbor and setting its value for next to the object assigned to first link in the double-ended linked list.', 'Creating a new neighbor involves passing the homeowner name and house number into the new neighbor.', 'Explaining the process of inserting into the last position of the linked list, involving assigning values and updating references for the new element.', "Detailing the steps for inserting into the first position of the linked list, including handling the scenario when the list is empty and when it's not.", 'Creating a display method for the linked list to easily showcase its elements.']}