title
Linked List - Data Structures & Algorithms Tutorials in Python #4
description
Linked list is a data structure similar to array in a sense that it stores bunch of items. But unlike array, linked lists are not stored in contiguous memory locations. They are instead chained by an element storing address location of next element. This makes insertion very easy. Also unlike dynamic arrays you don't have to pre-allocate some memory capacity. In this tutorial we will go through some theory first and then write python code to implement linked list. In the end we have an interesting exercise for you to solve.
Code: https://github.com/codebasics/data-structures-algorithms-python/tree/master/data_structures/3_LinkedList/3_linked_list.py
Exercise Link: https://github.com/codebasics/data-structures-algorithms-python/tree/master/data_structures/3_LinkedList/3_linked_list_exercise.md
Topics
00:00 Introduction
00:18 Issues with arrays that linked list solves
05:54 Doubly linked list
06:37 Big O analysis (array vs linked list)
08:02 Python implementation
26:00 Exercise
#linkedlist #pythonlinkedlist #datastructures #algorithms #python
Do you want to learn technology from me? Check https://codebasics.io/?utm_source=description&utm_medium=yt&utm_campaign=description&utm_id=description for my affordable video courses.
Next Video: https://www.youtube.com/watch?v=ea8BRGxGmlA&list=PLeo1K3hjS3uu_n_a__MI_KktGTLYopZ12&index=5
Previous video: https://www.youtube.com/watch?v=gDqQf4Ekr2A&list=PLeo1K3hjS3uu_n_a__MI_KktGTLYopZ12&index=3
Complete playlist:https://www.youtube.com/playlist?list=PLeo1K3hjS3uu_n_a__MI_KktGTLYopZ12
🌎 My Website For Video Courses: https://codebasics.io/?utm_source=description&utm_medium=yt&utm_campaign=description&utm_id=description
Need help building software or data analytics and AI solutions? My company https://www.atliq.com/ can help. Click on the Contact button on that website.
#️⃣ Social Media #️⃣
🔗 Discord: https://discord.gg/r42Kbuk
📸 Dhaval's Personal Instagram: https://www.instagram.com/dhavalsays/
📸 Codebasics Instagram: https://www.instagram.com/codebasicshub/
🔊 Facebook: https://www.facebook.com/codebasicshub
📱 Twitter: https://twitter.com/codebasicshub
📝 Linkedin (Personal): https://www.linkedin.com/in/dhavalsays/
📝 Linkedin (Codebasics): https://www.linkedin.com/company/codebasics/
🔗 Patreon: https://www.patreon.com/codebasics?fan_landing=true
detail
{'title': 'Linked List - Data Structures & Algorithms Tutorials in Python #4', 'heatmap': [{'end': 577.325, 'start': 474.424, 'weight': 0.946}, {'end': 712.771, 'start': 651.675, 'weight': 0.761}], 'summary': 'Tutorial series in python covers the implementation and operations of linked lists, comparing them with arrays and dynamic arrays while discussing complexities and coding exercises. it includes discussions on insertion, removal, manipulation, and coding exercises, with examples of specific operations and their outcomes.', 'chapters': [{'end': 35.386, 'segs': [{'end': 35.386, 'src': 'embed', 'start': 0.209, 'weight': 0, 'content': [{'end': 7.872, 'text': "We will be implementing linked list in Python today and we'll go through various operations on the linked list and the big O complexity.", 'start': 0.209, 'duration': 7.663}, {'end': 12.454, 'text': "In the end, as usual, we'll have an interesting exercise for you to solve.", 'start': 8.472, 'duration': 3.982}, {'end': 14.675, 'text': 'And here is the list of topics.', 'start': 12.874, 'duration': 1.801}, {'end': 18.196, 'text': 'So if you want to skip ahead to specific topic, feel free.', 'start': 14.715, 'duration': 3.481}, {'end': 25.679, 'text': 'To understand linked list, we first need to look into array because there are some issues with arrays that linked list tries to solve.', 'start': 18.536, 'duration': 7.143}, {'end': 33.084, 'text': 'Here I have an array of stock prices and this is a memory layout of those stock prices.', 'start': 26.559, 'duration': 6.525}, {'end': 35.386, 'text': 'Basically, there are like five elements in this array.', 'start': 33.244, 'duration': 2.142}], 'summary': 'Implementing linked list in python, discussing operations and big o complexity, and addressing issues with arrays.', 'duration': 35.177, 'max_score': 0.209, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU209.jpg'}], 'start': 0.209, 'title': 'Python linked list implementation', 'summary': 'Will cover the implementation of linked list in python, including various operations and big o complexity, with an array comparison. it will conclude with an exercise and discuss the array of stock prices and its memory layout.', 'chapters': [{'end': 35.386, 'start': 0.209, 'title': 'Python linked list implementation', 'summary': 'Will cover the implementation of linked list in python, including various operations and big o complexity, with an array comparison, and will conclude with an exercise. the array of stock prices and its memory layout will be discussed.', 'duration': 35.177, 'highlights': ['The chapter will cover the implementation of linked list in Python, including various operations and big O complexity.', 'To understand linked list, we first need to look into array because there are some issues with arrays that linked list tries to solve.', 'Here I have an array of stock prices and this is a memory layout of those stock prices.']}], 'duration': 35.177, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU209.jpg', 'highlights': ['The chapter will cover the implementation of linked list in Python, including various operations and big O complexity.', 'To understand linked list, we first need to look into array because there are some issues with arrays that linked list tries to solve.', 'Here I have an array of stock prices and this is a memory layout of those stock prices.']}, {'end': 482.832, 'segs': [{'end': 90.641, 'src': 'embed', 'start': 35.646, 'weight': 0, 'content': [{'end': 47.875, 'text': 'If you want to insert an element 284 at location number one, then it will insert 284 at location number one and it will swap all the elements right?', 'start': 35.646, 'duration': 12.229}, {'end': 51.898, 'text': 'So it will copy 305 from location number one to two 320 from.', 'start': 47.915, 'duration': 3.983}, {'end': 55.38, 'text': '2 to 3 and so on.', 'start': 53.679, 'duration': 1.701}, {'end': 59.443, 'text': 'So the array insertion complexity is order of n.', 'start': 55.64, 'duration': 3.803}, {'end': 64.887, 'text': "Let's try to go a little deeper into detail and see how exactly this works.", 'start': 59.443, 'duration': 5.444}, {'end': 73.773, 'text': 'When you create an empty list in Python internally in the memory, it will allocate some capacity for that list.', 'start': 65.247, 'duration': 8.526}, {'end': 76.655, 'text': 'Python list is a dynamic array.', 'start': 74.093, 'duration': 2.562}, {'end': 81.598, 'text': 'Now, if you want to know the difference between static and dynamic array, I highly recommend you watch my array tutorial.', 'start': 76.855, 'duration': 4.743}, {'end': 85.078, 'text': 'Here it is allocating a capacity of five elements.', 'start': 82.096, 'duration': 2.982}, {'end': 90.641, 'text': 'And when you start inserting elements one by one, it will put those values in.', 'start': 85.558, 'duration': 5.083}], 'summary': 'Inserting 284 at location one swaps elements; array insertion complexity is o(n). python list is a dynamic array with an initial capacity of 5 elements.', 'duration': 54.995, 'max_score': 35.646, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU35646.jpg'}, {'end': 318.597, 'src': 'embed', 'start': 290.719, 'weight': 2, 'content': [{'end': 294.38, 'text': "because all you're doing is creating a new node and then modifying those links.", 'start': 290.719, 'duration': 3.661}, {'end': 298.642, 'text': 'Similarly, if you want to delete the element at the beginning, order of one.', 'start': 295.321, 'duration': 3.321}, {'end': 305.645, 'text': 'If you want to insert or delete the element at the end or in the middle, the complexity is order of n,', 'start': 299.462, 'duration': 6.183}, {'end': 308.406, 'text': 'because you have to iterate through those elements.', 'start': 305.645, 'duration': 2.761}, {'end': 312.331, 'text': 'This data structure is called linked list.', 'start': 310.089, 'duration': 2.242}, {'end': 315.294, 'text': 'It has two main benefits over an array.', 'start': 313.172, 'duration': 2.122}, {'end': 318.597, 'text': "First, you don't need to preallocate the space.", 'start': 316.275, 'duration': 2.322}], 'summary': 'Linked list offers flexibility with order of 1 complexity for deleting at the beginning, and order of n complexity for inserting or deleting at the end or in the middle.', 'duration': 27.878, 'max_score': 290.719, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU290719.jpg'}, {'end': 457.525, 'src': 'embed', 'start': 403.757, 'weight': 3, 'content': [{'end': 415.085, 'text': 'The one advantage array has over linked list is, if you know the index of your element in array, its order of one, which is a constant time operation.', 'start': 403.757, 'duration': 11.328}, {'end': 424.673, 'text': 'because if you want to access fifth element, you just say your array in bracket five and you get that element in a constant time.', 'start': 415.085, 'duration': 9.588}, {'end': 433.535, 'text': 'In case of link list, if you want to access fifth element, you have to go through first, second, third, fourth, etc.', 'start': 425.413, 'duration': 8.122}, {'end': 435.475, 'text': 'elements and you have to follow those links.', 'start': 433.575, 'duration': 1.9}, {'end': 445.877, 'text': 'If you want to insert and delete element at the start, in array it is order of n because remember you have to copy those values.', 'start': 437.395, 'duration': 8.482}, {'end': 452.699, 'text': "In link list you don't, hence the complexity is order of 1.", 'start': 446.797, 'duration': 5.902}, {'end': 457.525, 'text': 'Inserting deleting element at the end is order of one in array.', 'start': 452.699, 'duration': 4.826}], 'summary': 'Arrays have constant time access, while linked lists require traversal. insertion and deletion have different complexities in arrays and linked lists.', 'duration': 53.768, 'max_score': 403.757, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU403757.jpg'}], 'start': 35.646, 'title': 'Array insertion complexity and dynamic array vs linked list', 'summary': 'Discusses the o(n) complexity of array insertion and the internal allocation of capacity in python. it also compares the inefficiency of dynamic arrays with the advantages of linked lists, highlighting their easy insertion and traversal, and provides examples of big o complexities for different operations.', 'chapters': [{'end': 90.641, 'start': 35.646, 'title': 'Array insertion complexity', 'summary': 'Discusses the array insertion complexity which is o(n) and explains the internal allocation of capacity for dynamic arrays in python.', 'duration': 54.995, 'highlights': ['Python list is a dynamic array. The chapter explains that Python list is a dynamic array, which is relevant for understanding the internal allocation of capacity for lists in Python.', 'The array insertion complexity is order of n. The chapter highlights that the array insertion complexity is O(n), providing a quantifiable measure of the complexity of array insertion.', 'It will allocate some capacity for that list. The chapter mentions the allocation of capacity for an empty list, which is important for understanding the internal working of dynamic arrays.']}, {'end': 482.832, 'start': 91.701, 'title': 'Dynamic array vs linked list', 'summary': 'Discusses the inefficiency of dynamic arrays in terms of insertion and the advantages of linked lists, especially in terms of easy insertion and traversal, with examples of big o complexities for different operations.', 'duration': 391.131, 'highlights': ['Linked list allows easy insertion and deletion at the beginning with complexity of order of one, while in dynamic array it is order of n. Easy insertion and deletion at the beginning, complexity comparison between linked list and dynamic array.', "Accessing the element at a specific index in an array is order of one, while in linked list it's order of n. Comparison of accessing specific index complexity between array and linked list.", 'Inserting and deleting elements at the end is order of one in array, and order of n in linked list. Comparison of complexity for inserting and deleting elements at the end between array and linked list.']}], 'duration': 447.186, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU35646.jpg', 'highlights': ['Python list is a dynamic array, relevant for understanding internal allocation of capacity.', 'Array insertion complexity is O(n), providing a quantifiable measure of the complexity.', 'Linked list allows easy insertion and deletion at the beginning with complexity of O(1), compared to O(n) in dynamic array.', "Accessing the element at a specific index in an array is O(1), while in linked list it's O(n).", 'Inserting and deleting elements at the end is O(1) in array, and O(n) in linked list.']}, {'end': 823.299, 'segs': [{'end': 544.203, 'src': 'embed', 'start': 482.832, 'weight': 0, 'content': [{'end': 487.076, 'text': "i have opened pycharm and i've created two classes here.", 'start': 482.832, 'duration': 4.244}, {'end': 492.861, 'text': 'the first class is a node class which represents an individual element in the linked list.', 'start': 487.076, 'duration': 5.785}, {'end': 494.902, 'text': 'It has two class members.', 'start': 493.261, 'duration': 1.641}, {'end': 496.463, 'text': 'One is data.', 'start': 495.563, 'duration': 0.9}, {'end': 500.786, 'text': 'The second one is next, which is a pointer to the next element.', 'start': 496.964, 'duration': 3.822}, {'end': 505.71, 'text': 'Data can contain integers, numbers or complex objects.', 'start': 501.727, 'duration': 3.983}, {'end': 514.316, 'text': 'The second class is a linked list class where you need a head variable which points to the head of the linked list.', 'start': 506.831, 'duration': 7.485}, {'end': 521.826, 'text': "first i'm going to implement a method called insert at beginning.", 'start': 515.84, 'duration': 5.986}, {'end': 532.338, 'text': 'so what this method is doing is it is taking data value and inserting that at the beginning of the linked list.', 'start': 521.826, 'duration': 10.512}, {'end': 544.203, 'text': "let's say, now you can create a node with value data and then the next element for that node.", 'start': 532.338, 'duration': 11.865}], 'summary': 'Pycharm used to create node and linked list classes for data insertion.', 'duration': 61.371, 'max_score': 482.832, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU482832.jpg'}, {'end': 615.063, 'src': 'embed', 'start': 577.325, 'weight': 3, 'content': [{'end': 580.406, 'text': 'so we will test this method out.', 'start': 577.325, 'duration': 3.081}, {'end': 585.907, 'text': 'but for testing this we need one utility function called print.', 'start': 580.406, 'duration': 5.501}, {'end': 588.808, 'text': 'so now i am going to print my linked list.', 'start': 585.907, 'duration': 2.901}, {'end': 602.227, 'text': "first thing in this function is if, let's say, my head is blank, i have a blank link list,", 'start': 592.179, 'duration': 10.048}, {'end': 615.063, 'text': 'then i want to print that my link list is empty and return If it is not blank.', 'start': 602.227, 'duration': 12.836}], 'summary': 'Testing a method on a linked list with a print utility function.', 'duration': 37.738, 'max_score': 577.325, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU577325.jpg'}, {'end': 712.771, 'src': 'heatmap', 'start': 651.675, 'weight': 0.761, 'content': [{'end': 661.802, 'text': 'And in that string, I will append that data from the string.', 'start': 651.675, 'duration': 10.127}, {'end': 667.085, 'text': 'And I will just use this character just to show kind of the link between the two elements.', 'start': 662.522, 'duration': 4.563}, {'end': 670.868, 'text': 'And then print.', 'start': 669.207, 'duration': 1.661}, {'end': 675.382, 'text': 'that llstr.', 'start': 672.919, 'duration': 2.463}, {'end': 677.804, 'text': "let's taste these two methods out.", 'start': 675.382, 'duration': 2.422}, {'end': 685.732, 'text': 'so first i am going to create my link list and insert some values.', 'start': 677.804, 'duration': 7.928}, {'end': 688.134, 'text': "so let's say i insert value at the beginning.", 'start': 685.732, 'duration': 2.402}, {'end': 696.726, 'text': "so i inserted 5, i inserted, Let's say, 89 and then I'm printing that.", 'start': 688.134, 'duration': 8.592}, {'end': 701.288, 'text': 'So let me remove this extra space.', 'start': 698.387, 'duration': 2.901}, {'end': 705.349, 'text': 'Right click run edit and it runs.', 'start': 702.228, 'duration': 3.121}, {'end': 711.591, 'text': 'So you can see that first I inserted five and then in front of that I inserted 89.', 'start': 706.089, 'duration': 5.502}, {'end': 712.771, 'text': 'Hence it printed 89 and five.', 'start': 711.591, 'duration': 1.18}], 'summary': 'Demonstration of inserting values in a linked list, resulting in 89 and 5 being printed.', 'duration': 61.096, 'max_score': 651.675, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU651675.jpg'}, {'end': 746.588, 'src': 'embed', 'start': 720.174, 'weight': 5, 'content': [{'end': 725.317, 'text': 'That way you get understanding of internally how linked list is working.', 'start': 720.174, 'duration': 5.143}, {'end': 732.541, 'text': 'So my linked list LL is here and my head is pointing to data, which is 89.', 'start': 725.357, 'duration': 7.184}, {'end': 736.863, 'text': 'Then it has a next element and next element is also of type node.', 'start': 732.541, 'duration': 4.322}, {'end': 740.905, 'text': 'the value is 5 and the next to that is none.', 'start': 737.683, 'duration': 3.222}, {'end': 746.588, 'text': "now I'm going to implement next method, which is inserting at end in this method.", 'start': 740.905, 'duration': 5.683}], 'summary': 'Implementing linked list with head pointing to 89 and next element with value 5.', 'duration': 26.414, 'max_score': 720.174, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU720174.jpg'}], 'start': 482.832, 'title': 'Implementing linked list in python', 'summary': 'Covers the implementation of linked list in python using two classes: node and linked list, and discusses creation, insertion at the beginning and end, iteration, and printing of the linked list.', 'chapters': [{'end': 577.325, 'start': 482.832, 'title': 'Linked list implementation in python', 'summary': 'Introduces the implementation of linked list in python using two classes: node and linked list, and explains the method insert at beginning, showcasing the process of inserting a new node at the beginning of the linked list.', 'duration': 94.493, 'highlights': ['The chapter introduces the implementation of linked list in Python using two classes: node and linked list. It explains the creation of two classes in Python, namely node and linked list, to represent individual elements in the linked list and the linked list itself.', 'The method insert at beginning is explained, showcasing the process of inserting a new node at the beginning of the linked list. The method insert at beginning is demonstrated, which involves inserting a new node at the beginning of the linked list, effectively updating the head variable to point to the newly inserted node.', 'The node class represents an individual element in the linked list. The node class is defined to contain data and a pointer to the next element in the linked list, allowing the storage of integers, numbers, or complex objects.']}, {'end': 823.299, 'start': 577.325, 'title': 'Implementing linked list in python', 'summary': 'Discusses the implementation of linked list in python, covering the creation, insertion at the beginning and end, iteration, and printing of the linked list.', 'duration': 245.974, 'highlights': ['Creating a utility function called print to test the implementation of linked list.', 'Inserting values at the beginning and end of the linked list and printing the linked list.', 'Iterating through the linked list, accessing elements one by one, and understanding the internal working by debugging.']}], 'duration': 340.467, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU482832.jpg', 'highlights': ['The chapter introduces the implementation of linked list in Python using two classes: node and linked list.', 'The method insert at beginning is explained, showcasing the process of inserting a new node at the beginning of the linked list.', 'The node class represents an individual element in the linked list.', 'Creating a utility function called print to test the implementation of linked list.', 'Inserting values at the beginning and end of the linked list and printing the linked list.', 'Iterating through the linked list, accessing elements one by one, and understanding the internal working by debugging.']}, {'end': 1083.47, 'segs': [{'end': 957.96, 'src': 'embed', 'start': 862.113, 'weight': 1, 'content': [{'end': 866.835, 'text': 'You can also remove these values and just keep on inserting at the end.', 'start': 862.113, 'duration': 4.722}, {'end': 875.537, 'text': "So let's say I want to insert 79 first, then one, and then some big value.", 'start': 866.875, 'duration': 8.662}, {'end': 881.519, 'text': 'And when I run this, I will see 79, one and nine, eight, seven, six.', 'start': 876.678, 'duration': 4.841}, {'end': 883.52, 'text': 'So this is working as expected.', 'start': 881.539, 'duration': 1.981}, {'end': 894.007, 'text': 'the next method i want to implement will take a list of values as an input and it will create a new fresh link list.', 'start': 884.961, 'duration': 9.046}, {'end': 904.654, 'text': "okay, so here in this link list, first i will say self dot head is none, because i'm wiping out all the current values and i am inserting new values.", 'start': 894.007, 'duration': 10.647}, {'end': 914.141, 'text': "and the way it will look like is let's say, you create a new link list and then you just call, for example, this method.", 'start': 904.654, 'duration': 9.487}, {'end': 919.704, 'text': 'so I want to insert all these values and it should create a link list out of that.', 'start': 915.561, 'duration': 4.143}, {'end': 934.373, 'text': 'okay, so for that I have to iterate through that input list and I can simply say insert at the end those values,', 'start': 919.704, 'duration': 14.669}, {'end': 938.016, 'text': 'because I have this insert at end function which I can use.', 'start': 934.373, 'duration': 3.643}, {'end': 944.907, 'text': "okay, so let's run this function Voila.", 'start': 938.016, 'duration': 6.891}, {'end': 945.507, 'text': 'so this works.', 'start': 944.907, 'duration': 0.6}, {'end': 950.232, 'text': 'See it will just create a link list out of all these values.', 'start': 945.527, 'duration': 4.705}, {'end': 954.576, 'text': 'Alright, now I have this function.', 'start': 951.613, 'duration': 2.963}, {'end': 957.96, 'text': 'The next step is to implement a function.', 'start': 954.737, 'duration': 3.223}], 'summary': 'Implementing methods to insert and create a new linked list from values.', 'duration': 95.847, 'max_score': 862.113, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU862113.jpg'}, {'end': 1043.346, 'src': 'embed', 'start': 982.868, 'weight': 0, 'content': [{'end': 993.792, 'text': "So length of my linked list is ll dot get length, and when you run it you can see that it's saying four, because i have four elements in my list.", 'start': 982.868, 'duration': 10.924}, {'end': 1001.456, 'text': 'now this get length length function is going to be useful in few other methods that we are going to implement.', 'start': 993.792, 'duration': 7.664}, {'end': 1008.759, 'text': 'so now i want to implement a method which can remove an element at a given index.', 'start': 1001.456, 'duration': 7.303}, {'end': 1027.163, 'text': 'okay, so, for example, i want to call something like this okay, and what this should do is it should remove the element at index 2, which is 0, 1, 2..', 'start': 1008.759, 'duration': 18.404}, {'end': 1031.847, 'text': 'so I want to create this link list and then remove grapes from that link list.', 'start': 1027.163, 'duration': 4.684}, {'end': 1033.269, 'text': 'how do I do that?', 'start': 1031.847, 'duration': 1.422}, {'end': 1040.044, 'text': 'you just implement this method, saying that remove at this index.', 'start': 1033.269, 'duration': 6.775}, {'end': 1043.346, 'text': 'so i want to remove the element at this particular index.', 'start': 1040.044, 'duration': 3.302}], 'summary': 'The linked list has a length of 4 elements, and a method to remove an element at a given index is being implemented.', 'duration': 60.478, 'max_score': 982.868, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU982868.jpg'}], 'start': 823.599, 'title': 'Linked list operations', 'summary': 'Covers the creation and manipulation of linked list nodes, insertion and removal of values, and obtaining the length of the linked list, resulting in a list of 89, 5, and 79, with a length of 4 and the removal of an element at index 2 being discussed.', 'chapters': [{'end': 894.007, 'start': 823.599, 'title': 'Linked list node operations', 'summary': 'Demonstrates the creation and manipulation of linked list nodes, including insertion and removal of values, resulting in a list of 89, 5, and 79, with the ability to create a new linked list from a list of values.', 'duration': 70.408, 'highlights': ['The chapter demonstrates the insertion of values into a linked list, resulting in the list 89, 5, and 79.', 'It also showcases the ability to remove values and continuously insert new values at the end of the linked list.', 'The method to create a new linked list from a list of values is also introduced.']}, {'end': 957.96, 'start': 894.007, 'title': 'Linked list insertion method', 'summary': 'Discusses the process of creating a linked list by iterating through an input list and using the insert at end function to insert new values, resulting in the successful creation of the linked list.', 'duration': 63.953, 'highlights': ['By iterating through the input list and using the insert at end function, a new linked list is successfully created.', 'The insert at end function is used to add values to the linked list, demonstrating its practical application.', 'The initial step involves wiping out all current values in the link list before inserting new values.']}, {'end': 1083.47, 'start': 959.941, 'title': 'Linked list operations', 'summary': 'Provides a simple explanation of how to obtain the length of a linked list and demonstrates the implementation of a method to remove an element at a given index, with the length of the linked list being 4 and the removal of an element at index 2 being discussed.', 'duration': 123.529, 'highlights': ['The length of the linked list is obtained using the get length function, resulting in a count of four elements.', "An explanation is provided for the implementation of a method to remove an element at a specific index, using the example of removing 'grapes' at index 2."]}], 'duration': 259.871, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU823599.jpg', 'highlights': ['The length of the linked list is obtained using the get length function, resulting in a count of four elements.', 'The chapter demonstrates the insertion of values into a linked list, resulting in the list 89, 5, and 79.', 'It also showcases the ability to remove values and continuously insert new values at the end of the linked list.', "An explanation is provided for the implementation of a method to remove an element at a specific index, using the example of removing 'grapes' at index 2.", 'By iterating through the input list and using the insert at end function, a new linked list is successfully created.', 'The insert at end function is used to add values to the linked list, demonstrating its practical application.', 'The method to create a new linked list from a list of values is also introduced.', 'The initial step involves wiping out all current values in the link list before inserting new values.']}, {'end': 1432.991, 'segs': [{'end': 1142.448, 'src': 'embed', 'start': 1110.995, 'weight': 0, 'content': [{'end': 1115.742, 'text': 'now good thing about python is it will do garbage collection for you.', 'start': 1110.995, 'duration': 4.747}, {'end': 1124.155, 'text': 'if you are using c++ type of language, then you have to explicitly clean up the memory associated with your head here.', 'start': 1115.742, 'duration': 8.413}, {'end': 1127.715, 'text': 'all right.', 'start': 1127.034, 'duration': 0.681}, {'end': 1133.78, 'text': "now that we have handled those two special cases, let's start with count.", 'start': 1127.715, 'duration': 6.065}, {'end': 1142.448, 'text': 'because you are removing the index and in linked list you have to manually maintain the count to reach that particular index.', 'start': 1133.78, 'duration': 8.668}], 'summary': 'Python performs automatic garbage collection, while in c++ manual memory cleanup is required. linked lists in python require manual count maintenance for index removal.', 'duration': 31.453, 'max_score': 1110.995, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU1110995.jpg'}, {'end': 1308.46, 'src': 'embed', 'start': 1217.028, 'weight': 1, 'content': [{'end': 1221.57, 'text': 'OK, I hope you can visualize that and once you achieve that you just break out of the loop.', 'start': 1217.028, 'duration': 4.542}, {'end': 1225.512, 'text': "So that's it for this method.", 'start': 1223.711, 'duration': 1.801}, {'end': 1227.133, 'text': "Now let's test it.", 'start': 1226.373, 'duration': 0.76}, {'end': 1229.194, 'text': 'Right click run.', 'start': 1228.354, 'duration': 0.84}, {'end': 1239.54, 'text': 'OK, this did not work because I think I did not update this count.', 'start': 1234.297, 'duration': 5.243}, {'end': 1242.081, 'text': 'OK, so I need to update the count.', 'start': 1239.96, 'duration': 2.121}, {'end': 1253.948, 'text': 'when i run it, i find that grapes, which was at index 2 because 0, 1, 2.', 'start': 1246.215, 'duration': 7.733}, {'end': 1256.632, 'text': 'so see the grapes is removed.', 'start': 1253.948, 'duration': 2.684}, {'end': 1269.669, 'text': 'Now, in this particular list, if I say remove at 20, which is of course an invalid index, it should throw an exception, which it did.', 'start': 1259.446, 'duration': 10.223}, {'end': 1272.75, 'text': 'See, it threw that exception.', 'start': 1269.95, 'duration': 2.8}, {'end': 1277.212, 'text': "Also, if you put, let's say, some negative index, etc.", 'start': 1273.671, 'duration': 3.541}, {'end': 1280.273, 'text': ", again, it's going to throw exception that the index is invalid.", 'start': 1277.212, 'duration': 3.061}, {'end': 1294.368, 'text': 'next function i want to implement is insert at where i provide an index and the value, and it inserts figs, for example in this case,', 'start': 1282.777, 'duration': 11.591}, {'end': 1297.751, 'text': 'at the location zero which is in front of banana.', 'start': 1294.368, 'duration': 3.383}, {'end': 1301.834, 'text': 'okay, so i have first check.', 'start': 1297.751, 'duration': 4.083}, {'end': 1307.219, 'text': 'uh, the same check i did in the previous function, which is checking whether index is valid or not.', 'start': 1301.834, 'duration': 5.385}, {'end': 1308.46, 'text': "let's say, your index is valid.", 'start': 1307.219, 'duration': 1.241}], 'summary': 'Testing method for removing, updating, and inserting items in a list.', 'duration': 91.432, 'max_score': 1217.028, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU1217028.jpg'}], 'start': 1083.47, 'title': 'Linked list operations', 'summary': 'Covers removal and insertion operations in a linked list, including specific conditions for head removal, automatic memory cleanup in python, removal and insertion at specific indexes, and handling invalid indexes and exceptions.', 'chapters': [{'end': 1133.78, 'start': 1083.47, 'title': 'Linked list removal operations', 'summary': 'Discusses the removal of elements from a linked list, covering the specific conditions for removing the head and the automatic memory cleanup in python, emphasizing the simplicity and efficiency of the process.', 'duration': 50.31, 'highlights': ['The process of removing the head from a linked list is simple, as setting the index to zero and updating the head to point to the next element enables efficient removal, with no explicit memory cleanup required in Python.', 'In Python, the automatic garbage collection simplifies memory cleanup, contrasting with the necessity for explicit memory management in languages like C++ when dealing with linked list removal operations.', 'The chapter introduces the concept of removing the head from a linked list by setting the index to zero and updating the head to point to the next element, emphasizing the simplicity of the process.']}, {'end': 1432.991, 'start': 1133.78, 'title': 'Linked list index removal and insertion', 'summary': 'Discusses the process of removing and inserting elements at specific indexes in a linked list, demonstrating the removal of an element at a given index and the insertion of an element at a given index, while also testing for invalid indexes and exceptions.', 'duration': 299.211, 'highlights': ["The process of removing the element at a given index in a linked list is explained, where the algorithm stops at the previous element to modify the links, and a test run successfully removes the 'grapes' element at index 2. Successful removal of the 'grapes' element at index 2.", 'The demonstration of handling exceptions for invalid indexes in the removal process, showcasing the successful throwing of an exception when attempting to remove an element at index 20 or a negative index. Successful throwing of an exception for invalid index removal.', "The implementation of inserting an element at a specific index in the linked list is explained, including the handling of the special case of inserting at the beginning, and the successful insertion of 'figs' at index 0. Successful insertion of 'figs' at index 0.", 'The explanation of the process for inserting an element at a given index, including the creation of a new node and the modification of the next pointer of the previous element. Detailed process for inserting an element at a given index.']}], 'duration': 349.521, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU1083470.jpg', 'highlights': ['Automatic memory cleanup in Python simplifies linked list removal operations.', "Successful removal of the 'grapes' element at index 2.", 'Successful throwing of an exception for invalid index removal.', "Successful insertion of 'figs' at index 0.", 'Detailed process for inserting an element at a given index.']}, {'end': 1694.926, 'segs': [{'end': 1469.535, 'src': 'embed', 'start': 1434.391, 'weight': 2, 'content': [{'end': 1437.332, 'text': 'Okay And once you do that, you can just break the loop.', 'start': 1434.391, 'duration': 2.941}, {'end': 1440.153, 'text': "Let's run this code.", 'start': 1438.932, 'duration': 1.221}, {'end': 1448.775, 'text': 'So here you can see that figs I tried to insert at the beginning and it did insert.', 'start': 1442.693, 'duration': 6.082}, {'end': 1450.236, 'text': 'So this was my original list.', 'start': 1448.795, 'duration': 1.441}, {'end': 1453.256, 'text': 'Now in the beginning, I have figs.', 'start': 1451.116, 'duration': 2.14}, {'end': 1457.458, 'text': "Let's try to call this method one more time.", 'start': 1454.977, 'duration': 2.481}, {'end': 1461.832, 'text': "And let's say now at this location.", 'start': 1457.578, 'duration': 4.254}, {'end': 1464.313, 'text': "so let's say zero, one, two.", 'start': 1461.832, 'duration': 2.481}, {'end': 1469.535, 'text': 'okay, before mango, i want to insert jackfruit.', 'start': 1464.313, 'duration': 5.222}], 'summary': "A code is run to insert 'figs' at the beginning of the list and 'jackfruit' before 'mango' at index 2.", 'duration': 35.144, 'max_score': 1434.391, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU1434391.jpg'}, {'end': 1601.899, 'src': 'embed', 'start': 1504.191, 'weight': 0, 'content': [{'end': 1509.272, 'text': 'In the linked list, you can insert string values, integer values, even complex objects.', 'start': 1504.191, 'duration': 5.081}, {'end': 1514.894, 'text': 'So let me just quickly demo you the integer values like.', 'start': 1509.732, 'duration': 5.162}, {'end': 1515.914, 'text': 'how does it look like?', 'start': 1514.894, 'duration': 1.02}, {'end': 1521.857, 'text': "So if I have something like this, where I'm inserting Couple of values and then I'm saying insert at the end,", 'start': 1515.934, 'duration': 5.923}, {'end': 1535.947, 'text': "So if I do run see I Had up till 99 and then it inserted 67 I can taste few other method as well, which is Let's say I want to remove less at 12.", 'start': 1521.897, 'duration': 14.05}, {'end': 1539.329, 'text': 'So the location of 12 is 0, 1, 2.', 'start': 1535.947, 'duration': 3.382}, {'end': 1550.718, 'text': 'so 2 ll dot print, Run it and it removed 2, and the code that i showed you is available on my github location.', 'start': 1539.329, 'duration': 11.389}, {'end': 1551.578, 'text': 'this is the location.', 'start': 1550.718, 'duration': 0.86}, {'end': 1555.682, 'text': "i'm gonna provide a link in the video description.", 'start': 1551.578, 'duration': 4.104}, {'end': 1560.686, 'text': 'so please check the video description for the code that i used in this tutorial.', 'start': 1555.682, 'duration': 5.004}, {'end': 1567.412, 'text': 'also, i have a very interesting exercise for you exercise is, as usual, the most interesting part of any tutorial.', 'start': 1560.686, 'duration': 6.726}, {'end': 1570.575, 'text': 'If you just watch the tutorial, you are not going to learn anything.', 'start': 1568.072, 'duration': 2.503}, {'end': 1571.296, 'text': "It's like swimming.", 'start': 1570.675, 'duration': 0.621}, {'end': 1573.258, 'text': 'I give this swimming example all the time.', 'start': 1571.536, 'duration': 1.722}, {'end': 1577.263, 'text': 'Unless you practice coding, you are not going to learn it.', 'start': 1573.759, 'duration': 3.504}, {'end': 1578.324, 'text': 'So forget it.', 'start': 1577.663, 'duration': 0.661}, {'end': 1582.489, 'text': "If you don't want to do exercise, you're wasting your time.", 'start': 1578.724, 'duration': 3.765}, {'end': 1587.514, 'text': 'So for this exercise, I have two problems that I want you to solve.', 'start': 1582.989, 'duration': 4.525}, {'end': 1595.937, 'text': 'The first one is implement these two additional methods in the linked list class that I already have.', 'start': 1589.076, 'duration': 6.861}, {'end': 1601.899, 'text': 'So you can take this particular class, copy the whole thing and add these two methods.', 'start': 1596.037, 'duration': 5.862}], 'summary': 'Tutorial on linked list insertion, removal, and exercise with additional methods.', 'duration': 97.708, 'max_score': 1504.191, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU1504191.jpg'}, {'end': 1668.233, 'src': 'embed', 'start': 1632.652, 'weight': 6, 'content': [{'end': 1635.874, 'text': 'OK, so do not look at the solution directly.', 'start': 1632.652, 'duration': 3.222}, {'end': 1640.317, 'text': 'Try to implement yourself first and then look at the solution.', 'start': 1636.374, 'duration': 3.943}, {'end': 1644.8, 'text': 'The second exercise is to implement doubly linked list.', 'start': 1641.177, 'duration': 3.623}, {'end': 1650.49, 'text': 'In double linked list, the only difference is you have a link to previous element as well.', 'start': 1646.129, 'duration': 4.361}, {'end': 1652.53, 'text': 'So your node class will look something like this.', 'start': 1650.53, 'duration': 2}, {'end': 1658.451, 'text': 'And you want to implement two function, which is print forward, print backward.', 'start': 1653.99, 'duration': 4.461}, {'end': 1668.233, 'text': 'And all other remaining methods that we had, you have to update those methods to account for your node dot previous element.', 'start': 1659.491, 'duration': 8.742}], 'summary': 'Implement doubly linked list with print forward and print backward functions', 'duration': 35.581, 'max_score': 1632.652, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU1632652.jpg'}], 'start': 1434.391, 'title': 'Linked list and coding exercise', 'summary': "Demonstrates insertion and removal in a linked list, including addition of 'figs' and 'jackfruit', insertion of integer values, and removal of '12'. it also emphasizes the importance of coding exercises, presenting problems involving linked list and doubly linked list implementations, highlighting the need for practice.", 'chapters': [{'end': 1555.682, 'start': 1434.391, 'title': 'Linked list insertion and removal', 'summary': "Demonstrates the insertion and removal of elements in a linked list, showcasing the addition of 'figs' and 'jackfruit' at specific indices, the insertion of integer values, and the removal of '12' from the list, with the code available on the presenter's github.", 'duration': 121.291, 'highlights': ["The presenter showcases the insertion of 'figs' at the beginning of the original list, followed by the insertion of 'jackfruit' at index 2, providing a clear demonstration of linked list manipulation.", "The insertion of integer values, including the addition of '67' at the end of the list, illustrates the flexibility of the linked list in accommodating various data types.", "The removal of '12' from the list at index 2 is effectively demonstrated, showcasing the functionality of removing specific elements from a linked list.", 'The presenter emphasizes the availability of the demonstrated code on their GitHub, providing viewers with access to the practical implementation of the showcased concepts.']}, {'end': 1694.926, 'start': 1555.682, 'title': 'Coding exercise: linked list and doubly linked list', 'summary': 'Covers the importance of coding exercises, presenting two problems to solve involving implementing additional methods in a linked list class and creating a doubly linked list, emphasizing the need for practice before looking at the solutions.', 'duration': 139.244, 'highlights': ['The chapter emphasizes the importance of practicing coding exercises, stating that simply watching tutorials without practice is ineffective.', 'Two problems are presented for the exercise, involving implementing additional methods in the linked list class and creating a doubly linked list.', 'The first exercise requires adding methods for inserting and removing elements by value, and the second exercise involves implementing a doubly linked list with functions for printing forward and backward.']}], 'duration': 260.535, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/qp8u-frRAnU/pics/qp8u-frRAnU1434391.jpg', 'highlights': ['The presenter emphasizes the availability of the demonstrated code on their GitHub, providing viewers with access to the practical implementation of the showcased concepts.', "The insertion of integer values, including the addition of '67' at the end of the list, illustrates the flexibility of the linked list in accommodating various data types.", "The presenter showcases the insertion of 'figs' at the beginning of the original list, followed by the insertion of 'jackfruit' at index 2, providing a clear demonstration of linked list manipulation.", "The removal of '12' from the list at index 2 is effectively demonstrated, showcasing the functionality of removing specific elements from a linked list.", 'The chapter emphasizes the importance of practicing coding exercises, stating that simply watching tutorials without practice is ineffective.', 'Two problems are presented for the exercise, involving implementing additional methods in the linked list class and creating a doubly linked list.', 'The first exercise requires adding methods for inserting and removing elements by value, and the second exercise involves implementing a doubly linked list with functions for printing forward and backward.']}], 'highlights': ['Linked list allows easy insertion and deletion at the beginning with complexity of O(1), compared to O(n) in dynamic array.', 'Inserting and deleting elements at the end is O(1) in array, and O(n) in linked list.', 'The method insert at beginning is explained, showcasing the process of inserting a new node at the beginning of the linked list.', 'The length of the linked list is obtained using the get length function, resulting in a count of four elements.', 'The chapter demonstrates the insertion of values into a linked list, resulting in the list 89, 5, and 79.', 'The presenter emphasizes the availability of the demonstrated code on their GitHub, providing viewers with access to the practical implementation of the showcased concepts.']}