title
3.3 Stack implementation using Linked List | Data Structures and Algorithm Tutorials
description
Here I have discussed Linked List implementation of Stack Data Structure. I have written a C program for Implementation of Stack using Linked List.
DSA Full Course: https: https://www.youtube.com/playlist?list=PLdo5W4Nhv31bbKJzrsKfMpo_grxuLl8LU
******************************************
See Complete Playlists:
C Programming Course: https://www.youtube.com/playlist?list=PLdo5W4Nhv31a8UcMN9-35ghv8qyFWD9_S
C++ Programming: https://www.youtube.com/playlist?list=PLdo5W4Nhv31YU5Wx1dopka58teWP9aCee
Python Full Course: https://www.youtube.com/playlist?list=PLdo5W4Nhv31bZSiqiOL5ta39vSnBxpOPT
Printing Pattern in C: https://www.youtube.com/playlist?list=PLdo5W4Nhv31Yu1igxTE2x0aeShbKtVcCy
DAA Course: https://www.youtube.com/playlist?list=PLdo5W4Nhv31ZTn2P9vF02bkb3SC8uiUUn
Placement Series: https://www.youtube.com/playlist?list=PLdo5W4Nhv31YvlDpJhvOYbM9Ap8UypgEy
Dynamic Programming: https://www.youtube.com/playlist?list=PLdo5W4Nhv31aBrJE1WS4MR9LRfbmZrAQu
Operating Systems: //www.youtube.com/playlist?list=PLdo5W4Nhv31a5ucW_S1K3-x6ztBRD-PNa
DBMS: https://www.youtube.com/playlist?list=PLdo5W4Nhv31b33kF46f9aFjoJPOkdlsRc
*********************************************
Connect & Contact Me:
Facebook: https://www.facebook.com/Jennys-Lectures-CSIT-Netjrf-316814368950701/
Quora: https://www.quora.com/profile/Jayanti-Khatri-Lamba
Instagram: https://www.instagram.com/jayantikhatrilamba/
#stack
#UGCNET
#jennyslectures
#datastructures
#computerscience
detail
{'title': '3.3 Stack implementation using Linked List | Data Structures and Algorithm Tutorials', 'heatmap': [{'end': 941.069, 'start': 856.12, 'weight': 0.707}, {'end': 1061.789, 'start': 1012.375, 'weight': 0.918}, {'end': 1136.832, 'start': 1102.137, 'weight': 0.708}], 'summary': 'Tutorial series covers the implementation of a stack using a linked list, emphasizing the lifo principle, time complexities, dynamic memory allocation, stack operations, and memory management. it provides code examples and demonstrations, offering a comprehensive understanding of data structures and algorithms.', 'chapters': [{'end': 93.061, 'segs': [{'end': 49.402, 'src': 'embed', 'start': 20.7, 'weight': 0, 'content': [{'end': 25.563, 'text': 'so i assume that you know the what is stack and what is linked list.', 'start': 20.7, 'duration': 4.863}, {'end': 28.865, 'text': 'right now we are going to implement stack using linked list.', 'start': 25.563, 'duration': 3.302}, {'end': 33.328, 'text': 'see, we will implement stack using linked list right.', 'start': 29.725, 'duration': 3.603}, {'end': 37.231, 'text': 'so you have to follow the rule of the stack.', 'start': 33.328, 'duration': 3.903}, {'end': 39.033, 'text': 'and what is that rule?', 'start': 37.231, 'duration': 1.802}, {'end': 40.574, 'text': 'that is LIFO principle.', 'start': 39.033, 'duration': 1.541}, {'end': 46.399, 'text': 'stack always follow what LIFO principle last in, first out right.', 'start': 40.574, 'duration': 5.825}, {'end': 49.402, 'text': 'that thing we have discussed in the previous video.', 'start': 46.399, 'duration': 3.003}], 'summary': 'Implement stack using linked list, following lifo principle.', 'duration': 28.702, 'max_score': 20.7, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ20700.jpg'}, {'end': 93.061, 'src': 'embed', 'start': 69.297, 'weight': 1, 'content': [{'end': 77.084, 'text': 'this insertion is also from this end and deletion would also perform from this end and this end is known as top.', 'start': 69.297, 'duration': 7.787}, {'end': 83.009, 'text': 'so the push and pop operations will be performed always from the top of the stack.', 'start': 77.084, 'duration': 5.925}, {'end': 84.191, 'text': 'and what is a linked list?', 'start': 83.009, 'duration': 1.182}, {'end': 88.115, 'text': 'see when i am saying a linked list, it means we are discussing about singly linked list.', 'start': 84.191, 'duration': 3.924}, {'end': 89.236, 'text': 'by default, right.', 'start': 88.115, 'duration': 1.121}, {'end': 90.698, 'text': 'so this is what a singly linked list.', 'start': 89.236, 'duration': 1.462}, {'end': 93.061, 'text': 'this is a node.', 'start': 91.96, 'duration': 1.101}], 'summary': 'The transcript discusses performing push and pop operations from the top of a singly linked list.', 'duration': 23.764, 'max_score': 69.297, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ69297.jpg'}], 'start': 0.029, 'title': 'Implementing stack using linked list', 'summary': 'Introduces the implementation of a stack using a linked list, emphasizing the lifo principle and the operations of insertion and deletion using a singly linked list.', 'chapters': [{'end': 93.061, 'start': 0.029, 'title': 'Implementing stack using linked list', 'summary': 'Introduces the implementation of a stack using a linked list, emphasizing the lifo principle and the operations of insertion and deletion using a singly linked list.', 'duration': 93.032, 'highlights': ['The stack follows the LIFO (Last In, First Out) principle, and the implementation using a linked list is discussed, highlighting the operations of push and pop from the top of the stack.', 'The chapter also mentions the concept of singly linked list as the default linked list type, emphasizing the structure of a node within the list.']}], 'duration': 93.032, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ29.jpg', 'highlights': ['The stack follows the LIFO (Last In, First Out) principle, and the implementation using a linked list is discussed, highlighting the operations of push and pop from the top of the stack.', 'The chapter also mentions the concept of singly linked list as the default linked list type, emphasizing the structure of a node within the list.']}, {'end': 766.665, 'segs': [{'end': 151.368, 'src': 'embed', 'start': 93.061, 'weight': 0, 'content': [{'end': 94.622, 'text': 'in the linked list, two parts are there.', 'start': 93.061, 'duration': 1.561}, {'end': 96.343, 'text': 'one is data part, one is address part.', 'start': 94.622, 'duration': 1.721}, {'end': 102.147, 'text': 'this address part or link part is containing address of the next node right, that is 400, here 100.', 'start': 96.343, 'duration': 5.804}, {'end': 109.832, 'text': 'the last node is containing null, because this is not pointing to any node and head pointer head is containing address of the first node.', 'start': 102.147, 'duration': 7.685}, {'end': 115.975, 'text': 'so when you are going to program the linked list, then what we have, the information we have, is what head pointer?', 'start': 109.832, 'duration': 6.143}, {'end': 117.276, 'text': 'only the head pointer.', 'start': 115.975, 'duration': 1.301}, {'end': 120.137, 'text': 'right, this is not head node, this is head pointer.', 'start': 117.276, 'duration': 2.861}, {'end': 121.177, 'text': 'this is what you can say.', 'start': 120.137, 'duration': 1.04}, {'end': 122.917, 'text': 'head node, the first node.', 'start': 121.177, 'duration': 1.74}, {'end': 124.978, 'text': 'right, we have only the head pointer.', 'start': 122.917, 'duration': 2.061}, {'end': 127.379, 'text': 'that is address of the first node.', 'start': 124.978, 'duration': 2.401}, {'end': 129.079, 'text': 'fine, this is what a linked list.', 'start': 127.379, 'duration': 1.7}, {'end': 132.82, 'text': 'now you have to implement stack using linked list.', 'start': 129.079, 'duration': 3.741}, {'end': 137.722, 'text': 'so here we will store the data in the form of nodes as well as we have to follow the rules.', 'start': 132.82, 'duration': 4.902}, {'end': 146.023, 'text': 'that is li fo principle, and we have discussed the push and pop operation, the two fundamental operations push and pop,', 'start': 137.722, 'duration': 8.301}, {'end': 148.345, 'text': 'is going to take order of one time.', 'start': 146.023, 'duration': 2.322}, {'end': 151.368, 'text': 'complexity is order of one only in the form of stack.', 'start': 148.345, 'duration': 3.023}], 'summary': 'Linked list contains nodes with data and address parts. implementing stack using linked list allows for push and pop operations with o(1) time complexity.', 'duration': 58.307, 'max_score': 93.061, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ93061.jpg'}, {'end': 252.693, 'src': 'embed', 'start': 226.045, 'weight': 3, 'content': [{'end': 230.826, 'text': 'if there are 10 node in the list and after that you want to insert, then you will have to traverse all the 10 nodes.', 'start': 226.045, 'duration': 4.781}, {'end': 233.967, 'text': 'means it depends on the number of nodes, order of n.', 'start': 230.826, 'duration': 3.141}, {'end': 239.328, 'text': 'second thing if you want to delete from the end only, in that case also time complexity would be order of n.', 'start': 233.967, 'duration': 5.361}, {'end': 245.15, 'text': 'so in case of pop also it would be order of n, because we cannot directly delete the data from the end.', 'start': 239.328, 'duration': 5.822}, {'end': 248.691, 'text': 'if you want to delete this data, then you will have to traverse the list till here.', 'start': 245.15, 'duration': 3.541}, {'end': 252.693, 'text': 'after then you will do what you will store here zero.', 'start': 249.631, 'duration': 3.062}], 'summary': 'Inserting and deleting in a list of 10 nodes has time complexity of o(n), as traversal is required.', 'duration': 26.648, 'max_score': 226.045, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ226045.jpg'}, {'end': 625.143, 'src': 'embed', 'start': 593.975, 'weight': 5, 'content': [{'end': 597.778, 'text': 'now top would point here and this node would contain address of this node.', 'start': 593.975, 'duration': 3.803}, {'end': 600.581, 'text': 'that is here 300, and top would point.', 'start': 597.778, 'duration': 2.803}, {'end': 604.244, 'text': 'suppose address is 400, so in top there would be 400.', 'start': 600.581, 'duration': 3.663}, {'end': 607.066, 'text': 'so this is how you can implement stack using linked list.', 'start': 604.244, 'duration': 2.822}, {'end': 613.672, 'text': 'you will always insert and delete from one end and that end would be the beginning.', 'start': 607.066, 'duration': 6.606}, {'end': 617.396, 'text': 'now we will write down the code for this push and pop operation.', 'start': 613.672, 'duration': 3.724}, {'end': 625.143, 'text': 'see here if you write the pop, it means after inserting only the three, three nodes, these three nodes, the popped item would be this one eight,', 'start': 617.396, 'duration': 7.747}], 'summary': 'Implement a stack using a linked list, inserting and deleting from one end, with an example of three nodes and an item popped after insertion.', 'duration': 31.168, 'max_score': 593.975, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ593975.jpg'}, {'end': 677.339, 'src': 'embed', 'start': 634.291, 'weight': 6, 'content': [{'end': 642.497, 'text': 'top is still pointing to here and if you want to delete, then always we will delete from the head only from the one end, only insertion and deletion.', 'start': 634.291, 'duration': 8.206}, {'end': 645.419, 'text': 'so when you will delete this thing, top would point to here.', 'start': 642.497, 'duration': 2.922}, {'end': 647.08, 'text': 'after that you can free this node.', 'start': 645.419, 'duration': 1.661}, {'end': 650.723, 'text': 'right now we will write down the code for this push and pop operations.', 'start': 647.08, 'duration': 3.643}, {'end': 653.805, 'text': 'so suppose in stack i want to push three elements.', 'start': 650.723, 'duration': 3.082}, {'end': 656.447, 'text': 'first is two, then three, then ten.', 'start': 653.805, 'duration': 2.642}, {'end': 661.851, 'text': 'i have called push three times right and we have passed the value.', 'start': 656.447, 'duration': 5.404}, {'end': 663.812, 'text': 'whatever i want to push, fine.', 'start': 661.851, 'duration': 1.961}, {'end': 665.233, 'text': 'after that i will display the data.', 'start': 663.812, 'duration': 1.421}, {'end': 667.754, 'text': 'after that we will call the peak function.', 'start': 665.233, 'duration': 2.521}, {'end': 672.376, 'text': 'peak means it would return the topmost element from the stack without removing that element.', 'start': 667.754, 'duration': 4.622}, {'end': 677.339, 'text': 'fine, pop means the topmost element would be popped out from the stack.', 'start': 672.376, 'duration': 4.963}], 'summary': 'Demonstrating stack operations: push, pop, and peak with example of pushing 3 elements and performing operations.', 'duration': 43.048, 'max_score': 634.291, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ634291.jpg'}], 'start': 93.061, 'title': 'Linked list and stack implementation', 'summary': 'Explains the concept of a linked list, emphasizing its structure and node roles. it also discusses implementing a stack using a linked list, focusing on time complexities and efficient push and pop operations, with code examples provided.', 'chapters': [{'end': 129.079, 'start': 93.061, 'title': 'Linked list concept', 'summary': 'Explains the concept of a linked list, emphasizing the structure of its nodes, the role of the head pointer, and the significance of addresses in its implementation.', 'duration': 36.018, 'highlights': ['The linked list comprises two parts: the data part and the address part, with the latter containing the address of the next node (e.g., 400 and 100 in the given example).', 'The last node contains null, indicating it does not point to any other node, while the head pointer holds the address of the first node.', 'When programming a linked list, only the head pointer is initially available, serving as the address of the first node.']}, {'end': 766.665, 'start': 129.079, 'title': 'Implementing stack using linked list', 'summary': 'Discusses the implementation of stack using linked list, emphasizing the time complexity of push and pop operations and the approach of always pushing and popping from the beginning of the list to achieve order of one time complexity, with code examples for push, pop, and peak functions.', 'duration': 637.586, 'highlights': ['Push and pop operations time complexity The time complexity for inserting and deleting from the end of the linked list is order of n, depending on the number of nodes, while inserting and deleting from the beginning of the list takes order of one time complexity, as it does not depend on the number of nodes present.', 'Implementation approach for stack using linked list The approach emphasizes always pushing and popping from the beginning of the list to achieve order of one time complexity, with the top pointer pointing to the beginning of the list and creating new nodes that point to the previous node, effectively implementing stack rules.', 'Code example for push operation The code example for the push operation includes the creation of a new node to store the pushed value and updating the top pointer to point to the new node, effectively adding the value to the stack.', 'Code example for pop operation The code example for the pop operation involves updating the top pointer to point to the next node after popping the topmost element, effectively removing the topmost element from the stack.', 'Code example for peak operation The code example for the peak operation involves returning the topmost element from the stack without removing it, allowing for accessing the topmost element without altering the stack.']}], 'duration': 673.604, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ93061.jpg', 'highlights': ['The linked list comprises two parts: the data part and the address part, with the latter containing the address of the next node (e.g., 400 and 100 in the given example).', 'The last node contains null, indicating it does not point to any other node, while the head pointer holds the address of the first node.', 'When programming a linked list, only the head pointer is initially available, serving as the address of the first node.', 'Push and pop operations time complexity The time complexity for inserting and deleting from the end of the linked list is order of n, depending on the number of nodes, while inserting and deleting from the beginning of the list takes order of one time complexity, as it does not depend on the number of nodes present.', 'Implementation approach for stack using linked list The approach emphasizes always pushing and popping from the beginning of the list to achieve order of one time complexity, with the top pointer pointing to the beginning of the list and creating new nodes that point to the previous node, effectively implementing stack rules.', 'Code example for push operation The code example for the push operation includes the creation of a new node to store the pushed value and updating the top pointer to point to the new node, effectively adding the value to the stack.', 'Code example for pop operation The code example for the pop operation involves updating the top pointer to point to the next node after popping the topmost element, effectively removing the topmost element from the stack.', 'Code example for peak operation The code example for the peak operation involves returning the topmost element from the stack without removing it, allowing for accessing the topmost element without altering the stack.']}, {'end': 1077.398, 'segs': [{'end': 825.68, 'src': 'embed', 'start': 787.037, 'weight': 0, 'content': [{'end': 791.879, 'text': 'but here, if you are using the linked list, means dynamic memory allocation, funda we are using.', 'start': 787.037, 'duration': 4.842}, {'end': 793.74, 'text': 'so no need to specify the stack size.', 'start': 791.879, 'duration': 1.861}, {'end': 797.181, 'text': 'this is what the advantage of using linked list.', 'start': 793.74, 'duration': 3.441}, {'end': 802.462, 'text': 'fine now, and for dynamic memory allocation we will use what malloc function.', 'start': 797.181, 'duration': 5.281}, {'end': 805.663, 'text': 'so i guess everybody knows the meaning of this line, because we have discussed many times.', 'start': 802.462, 'duration': 3.201}, {'end': 812.655, 'text': 'one node has been created and using malloc function, dynamic memory allocation syntax says we will take how much byte we want,', 'start': 806.613, 'duration': 6.042}, {'end': 814.236, 'text': 'how much byte in memory we want.', 'start': 812.655, 'duration': 1.581}, {'end': 816.777, 'text': 'size of struct node, the data type of this.', 'start': 814.236, 'duration': 2.541}, {'end': 818.437, 'text': 'this node is what struct node.', 'start': 816.777, 'duration': 1.66}, {'end': 820.498, 'text': 'fine, malloc would return a void pointer.', 'start': 818.437, 'duration': 2.061}, {'end': 825.68, 'text': 'that is why you have to typecast this thing, because the new node pointer is what pointer to a node.', 'start': 820.498, 'duration': 5.182}], 'summary': 'Using linked list allows dynamic memory allocation with malloc function.', 'duration': 38.643, 'max_score': 787.037, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ787037.jpg'}, {'end': 941.069, 'src': 'heatmap', 'start': 845.211, 'weight': 2, 'content': [{'end': 853.938, 'text': 'in 64, 4 bit compiler it would take 8 bytes right, and in typical compilers the integer is going to take 4 bytes somewhere.', 'start': 845.211, 'duration': 8.727}, {'end': 856.12, 'text': 'it is going to take 2 bytes.', 'start': 853.938, 'duration': 2.182}, {'end': 859.863, 'text': 'fine. so now here you will store in the data part we will store 2.', 'start': 856.12, 'duration': 3.743}, {'end': 862.345, 'text': 'how you will store that thing, how you can access this part.', 'start': 859.863, 'duration': 2.482}, {'end': 866.488, 'text': 'we can access the structure members using the pointer.', 'start': 863.186, 'duration': 3.302}, {'end': 868.809, 'text': 'only with this pointer is pointing to this node.', 'start': 866.488, 'duration': 2.321}, {'end': 880.616, 'text': 'so new node arrow and then this name of this part is data is equal to x, because in x we are going to receive this value 2 right.', 'start': 868.809, 'duration': 11.807}, {'end': 881.336, 'text': 'so here we have 2.', 'start': 880.616, 'duration': 0.72}, {'end': 889.021, 'text': 'now. now the next thing is simple rule is what here in the next part, what you will store new node.', 'start': 881.336, 'duration': 7.685}, {'end': 895.969, 'text': 'Next, here I am going to store the value whatever the value in top is equal to top.', 'start': 889.907, 'duration': 6.062}, {'end': 897.47, 'text': 'right?. In top I have null.', 'start': 895.969, 'duration': 1.501}, {'end': 898.511, 'text': 'so here we will store null.', 'start': 897.47, 'duration': 1.041}, {'end': 907.014, 'text': 'Fine?. Now, obviously, we have inserted this data in the stack, so top should point to this node, right?', 'start': 899.631, 'duration': 7.383}, {'end': 909.815, 'text': 'So now in top, what you will store?', 'start': 907.794, 'duration': 2.021}, {'end': 913.617, 'text': 'Address of this node, that is 100..', 'start': 910.155, 'duration': 3.462}, {'end': 919.459, 'text': 'And from where you will get this 100? See, in new node I have 100, so top is equal to new node.', 'start': 913.617, 'duration': 5.842}, {'end': 924.124, 'text': "that's it again.", 'start': 922.364, 'duration': 1.76}, {'end': 928.405, 'text': 'suppose if you call push is equal to 3, 3 would be passed.', 'start': 924.124, 'duration': 4.281}, {'end': 929.826, 'text': 'x is equal to now 3.', 'start': 928.405, 'duration': 1.421}, {'end': 933.807, 'text': 'fine again, a new node would be created.', 'start': 929.826, 'duration': 3.981}, {'end': 936.687, 'text': 'a new node would be created right now.', 'start': 933.807, 'duration': 2.88}, {'end': 938.788, 'text': 'this new node suppose address is 200.', 'start': 936.687, 'duration': 2.101}, {'end': 941.069, 'text': 'so now in new node pointer i have 200.', 'start': 938.788, 'duration': 2.281}], 'summary': 'In a 64-bit compiler, integers take 4 bytes, new data is stored as 2, and pointers are used to access and store values in the stack.', 'duration': 23.598, 'max_score': 845.211, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ845211.jpg'}, {'end': 929.826, 'src': 'embed', 'start': 899.631, 'weight': 5, 'content': [{'end': 907.014, 'text': 'Fine?. Now, obviously, we have inserted this data in the stack, so top should point to this node, right?', 'start': 899.631, 'duration': 7.383}, {'end': 909.815, 'text': 'So now in top, what you will store?', 'start': 907.794, 'duration': 2.021}, {'end': 913.617, 'text': 'Address of this node, that is 100..', 'start': 910.155, 'duration': 3.462}, {'end': 919.459, 'text': 'And from where you will get this 100? See, in new node I have 100, so top is equal to new node.', 'start': 913.617, 'duration': 5.842}, {'end': 924.124, 'text': "that's it again.", 'start': 922.364, 'duration': 1.76}, {'end': 928.405, 'text': 'suppose if you call push is equal to 3, 3 would be passed.', 'start': 924.124, 'duration': 4.281}, {'end': 929.826, 'text': 'x is equal to now 3.', 'start': 928.405, 'duration': 1.421}], 'summary': 'Discussed insertion in stack, top pointing to node, and 3 being pushed.', 'duration': 30.195, 'max_score': 899.631, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ899631.jpg'}, {'end': 1061.789, 'src': 'heatmap', 'start': 981.105, 'weight': 3, 'content': [{'end': 987.752, 'text': 'so in new node, after creating this, this node, the address is this one 300.', 'start': 981.105, 'duration': 6.647}, {'end': 991.837, 'text': 'fine, new node data means here we will store x in x.', 'start': 987.752, 'duration': 4.085}, {'end': 994.465, 'text': 'i have now 10 new node.', 'start': 991.837, 'duration': 2.628}, {'end': 995.606, 'text': 'next is equal to top.', 'start': 994.465, 'duration': 1.141}, {'end': 997.347, 'text': 'new node next is equal to top.', 'start': 995.606, 'duration': 1.741}, {'end': 1005.311, 'text': 'top is containing 200, means it is pointing to this node now and now top is equal to new node means top is pointing to this node.', 'start': 997.347, 'duration': 7.964}, {'end': 1009.193, 'text': 'that is here we will store 300 and this is what a stack.', 'start': 1005.311, 'duration': 3.882}, {'end': 1012.375, 'text': 'this is what a logical representation of stack right now.', 'start': 1009.193, 'duration': 3.182}, {'end': 1021.618, 'text': 'suppose if you call this display function, it means it should display first of all 10, then 3, then 2.', 'start': 1012.375, 'duration': 9.243}, {'end': 1023.98, 'text': 'right, because top is pointing to this node somewhere.', 'start': 1021.618, 'duration': 2.362}, {'end': 1029.185, 'text': 'you will find out that they will display the data from here 2, 3 and 10.', 'start': 1023.98, 'duration': 5.205}, {'end': 1030.986, 'text': 'but here we will implement this logic.', 'start': 1029.185, 'duration': 1.801}, {'end': 1033.308, 'text': 'fine, because from here only we can display.', 'start': 1030.986, 'duration': 2.322}, {'end': 1036.511, 'text': 'so first of all 10 we will display, then 3, then 2.', 'start': 1033.308, 'duration': 3.203}, {'end': 1038.152, 'text': 'so now how you will display the data.', 'start': 1036.511, 'duration': 1.641}, {'end': 1042.175, 'text': "see, see, in the push operation we haven't checked for the overflow condition.", 'start': 1038.152, 'duration': 4.023}, {'end': 1047.079, 'text': "why so because in the stack we haven't fixed the size.", 'start': 1042.175, 'duration': 4.904}, {'end': 1049.661, 'text': 'suppose we have fixed the size, that is three.', 'start': 1047.079, 'duration': 2.582}, {'end': 1051.062, 'text': "so in that case we haven't.", 'start': 1049.661, 'duration': 1.401}, {'end': 1051.502, 'text': 'we will.', 'start': 1051.062, 'duration': 0.44}, {'end': 1053.403, 'text': 'we are not able to insert fourth data.', 'start': 1051.502, 'duration': 1.901}, {'end': 1061.789, 'text': "that is why we checked overflow condition right when we were implementing stack using arrays, but here we haven't specified the size of the stack.", 'start': 1053.403, 'duration': 8.386}], 'summary': 'Implementation of a stack data structure with logical representation and example of overflow condition.', 'duration': 52.203, 'max_score': 981.105, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ981105.jpg'}], 'start': 766.665, 'title': 'Dynamic memory allocation in linked list and stack data structure basics', 'summary': 'Discusses the advantage of dynamic memory allocation in linked lists, highlighting the use of the malloc function and explains the basics of stack data structure, including the push operation, node creation, storage, and logical representation.', 'chapters': [{'end': 868.809, 'start': 766.665, 'title': 'Dynamic memory allocation in linked list', 'summary': 'Discusses the advantage of using dynamic memory allocation in linked lists, eliminating the need to specify stack size and using the malloc function to allocate memory for nodes.', 'duration': 102.144, 'highlights': ['Using dynamic memory allocation in linked lists eliminates the need to specify stack size, providing a major advantage over arrays.', 'The malloc function is used for dynamic memory allocation, allowing the allocation of memory based on the size of the struct node, typically 8 bytes in size.', 'Accessing the structure members is done using a pointer, enabling the storage and access of data within the allocated memory.']}, {'end': 1077.398, 'start': 868.809, 'title': 'Stack data structure basics', 'summary': 'Explains the push operation in a stack data structure, creating and storing nodes, and displaying the logical representation of the stack with a detailed step-by-step process.', 'duration': 208.589, 'highlights': ['Creating and storing nodes: The chapter explains the process of creating and storing nodes in a stack data structure, including the data values and addresses, with examples of 2, 3, and 10.', 'Logical representation of the stack: The logical representation of the stack is detailed, including how the nodes are linked and the order in which data would be displayed, with the example of 10, 3, and 2.', 'Explanation of push operation: The push operation is explained with examples of inserting values like 2, 3, and 10 into the stack, detailing the creation of new nodes and updating the top pointer.']}], 'duration': 310.733, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ766665.jpg', 'highlights': ['Using dynamic memory allocation in linked lists eliminates the need to specify stack size, providing a major advantage over arrays.', 'The malloc function is used for dynamic memory allocation, allowing the allocation of memory based on the size of the struct node, typically 8 bytes in size.', 'Accessing the structure members is done using a pointer, enabling the storage and access of data within the allocated memory.', 'Creating and storing nodes: The chapter explains the process of creating and storing nodes in a stack data structure, including the data values and addresses, with examples of 2, 3, and 10.', 'Logical representation of the stack: The logical representation of the stack is detailed, including how the nodes are linked and the order in which data would be displayed, with the example of 10, 3, and 2.', 'Explanation of push operation: The push operation is explained with examples of inserting values like 2, 3, and 10 into the stack, detailing the creation of new nodes and updating the top pointer.']}, {'end': 1338.976, 'segs': [{'end': 1160.809, 'src': 'heatmap', 'start': 1102.137, 'weight': 0, 'content': [{'end': 1104.74, 'text': 'temp is equal to top.', 'start': 1102.137, 'duration': 2.603}, {'end': 1109.666, 'text': 'it means temp is now containing whatever the top value, that is 300.', 'start': 1104.74, 'duration': 4.926}, {'end': 1111.669, 'text': 'so now temp is pointing to this node.', 'start': 1109.666, 'duration': 2.003}, {'end': 1115.627, 'text': 'Right Here you can check for underflow condition.', 'start': 1113.086, 'duration': 2.541}, {'end': 1117.107, 'text': 'If there is no node in the list.', 'start': 1115.707, 'duration': 1.4}, {'end': 1117.827, 'text': 'In that case.', 'start': 1117.187, 'duration': 0.64}, {'end': 1120.148, 'text': 'Obviously we cannot print anything.', 'start': 1118.567, 'duration': 1.581}, {'end': 1121.068, 'text': 'List is empty.', 'start': 1120.368, 'duration': 0.7}, {'end': 1122.908, 'text': 'Fine So here you can check.', 'start': 1121.448, 'duration': 1.46}, {'end': 1124.749, 'text': 'If top equal to equal to null.', 'start': 1123.008, 'duration': 1.741}, {'end': 1128.97, 'text': 'Right In that case here in printf you can say list is empty.', 'start': 1125.989, 'duration': 2.981}, {'end': 1130.93, 'text': 'Right In else part.', 'start': 1129.27, 'duration': 1.66}, {'end': 1132.991, 'text': 'What you will do.', 'start': 1132.411, 'duration': 0.58}, {'end': 1135.031, 'text': 'Obviously we are going to take a loop.', 'start': 1133.131, 'duration': 1.9}, {'end': 1136.832, 'text': 'So here I am taking a while loop.', 'start': 1135.431, 'duration': 1.401}, {'end': 1142.593, 'text': 'While Temp not equal to.', 'start': 1139.212, 'duration': 3.381}, {'end': 1146.024, 'text': 'null. right till.', 'start': 1143.323, 'duration': 2.701}, {'end': 1148.745, 'text': 'then what we are going to print?', 'start': 1146.024, 'duration': 2.721}, {'end': 1150.145, 'text': 'the data first of all.', 'start': 1148.745, 'duration': 1.4}, {'end': 1159.008, 'text': 'so here what you will write in printf, percentage d and temp data.', 'start': 1150.145, 'duration': 8.863}, {'end': 1160.809, 'text': 'this is how we are going to access this part.', 'start': 1159.008, 'duration': 1.801}], 'summary': 'Print the value of nodes in a list using a while loop until reaching null. if the list is empty, it will not print anything.', 'duration': 83.411, 'max_score': 1102.137, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ1102137.jpg'}, {'end': 1351.436, 'src': 'embed', 'start': 1319.21, 'weight': 1, 'content': [{'end': 1323.592, 'text': 'when you will call this peak, then it would print 10.', 'start': 1319.21, 'duration': 4.382}, {'end': 1326.333, 'text': 'fine, this is what the peak operation is.', 'start': 1323.592, 'duration': 2.741}, {'end': 1330.454, 'text': 'now we will see the coding for the pop operation.', 'start': 1326.333, 'duration': 4.121}, {'end': 1337.616, 'text': 'so now pop means this topmost element would be removed and after that the size of stack becomes here.', 'start': 1330.454, 'duration': 7.162}, {'end': 1338.976, 'text': 'now the size of stack is 3.', 'start': 1337.616, 'duration': 1.36}, {'end': 1351.436, 'text': "so now, after that size of stack becomes 2, means after popping this, the top should point to this node right, and if you don't delete this thing,", 'start': 1338.976, 'duration': 12.46}], 'summary': 'Demonstrating stack operations: peak prints 10, pop reduces stack size.', 'duration': 32.226, 'max_score': 1319.21, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ1319210.jpg'}], 'start': 1077.398, 'title': 'Stack operations', 'summary': 'Discusses displaying stack data using a temporary pointer, checking for underflow condition, and printing data. it also explains stack traversal, peek operation, and pop operation, resulting in the stack size becoming 3.', 'chapters': [{'end': 1160.809, 'start': 1077.398, 'title': 'Display stack data', 'summary': 'Discusses the process of displaying data from a stack by using a temporary pointer to traverse the stack, checking for underflow condition, and printing the data using a while loop, emphasizing the importance of checking for an empty list before displaying.', 'duration': 83.411, 'highlights': ['A temporary pointer, temp, is used to traverse the stack, starting from the top, to display the data in the stack, ensuring that the original top pointer remains unchanged.', 'The chapter emphasizes the importance of checking for an underflow condition by verifying if the list is empty before attempting to display any data from the stack.', 'The process involves using a while loop to iterate through the stack using the temp pointer and printing the data in each node until the end of the stack is reached.']}, {'end': 1338.976, 'start': 1160.809, 'title': 'Stack traversal and operations', 'summary': 'Explains the traversal and operations of a stack, showcasing a sequence of operations to traverse the stack, peek at the top element, and execute the pop operation, resulting in the stack size becoming 3.', 'duration': 178.167, 'highlights': ['The chapter demonstrates the traversal of a stack, printing the data 10, 3, and 2, showcasing the sequence of operations and resulting in the stack size becoming 3.', 'The explanation of the peek function illustrates how it displays the topmost element, in this case, accessing and printing the top element which is 10.', 'The coding for the pop operation is explained, indicating the removal of the topmost element and resulting in the stack size becoming 3.']}], 'duration': 261.578, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ1077398.jpg', 'highlights': ['The chapter emphasizes the importance of checking for an underflow condition by verifying if the list is empty before attempting to display any data from the stack.', 'The explanation of the peek function illustrates how it displays the topmost element, in this case, accessing and printing the top element which is 10.', 'The process involves using a while loop to iterate through the stack using the temp pointer and printing the data in each node until the end of the stack is reached.', 'The chapter demonstrates the traversal of a stack, printing the data 10, 3, and 2, showcasing the sequence of operations and resulting in the stack size becoming 3.', 'A temporary pointer, temp, is used to traverse the stack, starting from the top, to display the data in the stack, ensuring that the original top pointer remains unchanged.', 'The coding for the pop operation is explained, indicating the removal of the topmost element and resulting in the stack size becoming 3.']}, {'end': 1620.233, 'segs': [{'end': 1390.508, 'src': 'embed', 'start': 1363.763, 'weight': 0, 'content': [{'end': 1367.466, 'text': 'the memory is still allocated to this node and memory is very crucial resource.', 'start': 1363.763, 'duration': 3.703}, {'end': 1370.288, 'text': 'so you have to clean this thing.', 'start': 1368.206, 'duration': 2.082}, {'end': 1371.209, 'text': 'this is now garbage.', 'start': 1370.288, 'duration': 0.921}, {'end': 1373.171, 'text': 'now you have to clean this garbage.', 'start': 1371.209, 'duration': 1.962}, {'end': 1374.532, 'text': 'so simply you can do.', 'start': 1373.171, 'duration': 1.361}, {'end': 1379.457, 'text': 'you can free this node free and you, we can use a free function.', 'start': 1374.532, 'duration': 4.925}, {'end': 1384.402, 'text': 'that we have discussed when we were discussing the linked list concept and we can do, suppose pointer,', 'start': 1379.457, 'duration': 4.945}, {'end': 1388.927, 'text': 'one pointer is pointing to this node temp and we can pass free temp.', 'start': 1384.402, 'duration': 4.525}, {'end': 1390.508, 'text': 'after that this memory would be freed.', 'start': 1388.927, 'duration': 1.581}], 'summary': 'Allocate and deallocate memory efficiently to manage resources.', 'duration': 26.745, 'max_score': 1363.763, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ1363763.jpg'}, {'end': 1468.576, 'src': 'embed', 'start': 1435.998, 'weight': 2, 'content': [{'end': 1441.122, 'text': 'So here you can check if top equal to equal to null.', 'start': 1435.998, 'duration': 5.124}, {'end': 1447.248, 'text': 'So here you can print printf underflow, right? There is no node in the list else.', 'start': 1441.803, 'duration': 5.445}, {'end': 1454.024, 'text': 'now what you can do if you want to print the popped element.', 'start': 1449.901, 'duration': 4.123}, {'end': 1458.288, 'text': 'if you want to print that the popped element is 10.', 'start': 1454.024, 'duration': 4.264}, {'end': 1461.03, 'text': 'in that case what you will do see?', 'start': 1458.288, 'duration': 2.742}, {'end': 1465.633, 'text': 'first of all, here you can print print f.', 'start': 1461.03, 'duration': 4.603}, {'end': 1468.576, 'text': 'here you can write the popped element is percentage d.', 'start': 1465.633, 'duration': 2.943}], 'summary': 'Code checks for null, prints underflow, and pops element.', 'duration': 32.578, 'max_score': 1435.998, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ1435998.jpg'}, {'end': 1620.233, 'src': 'embed', 'start': 1570.89, 'weight': 3, 'content': [{'end': 1580.374, 'text': 'so now the output of this pop function would be 10, because we have deleted, we have print, printed this data, top data, now again, if you call peak,', 'start': 1570.89, 'duration': 9.484}, {'end': 1588.269, 'text': 'in that case it should print what 3 only, because now, after popping one data, the topmost element is 3.', 'start': 1580.374, 'duration': 7.895}, {'end': 1589.851, 'text': 'so it should print 3.', 'start': 1588.269, 'duration': 1.582}, {'end': 1595.656, 'text': 'and when you will display the function sorry, when you call the display function, then it would display 3, 2.', 'start': 1589.851, 'duration': 5.805}, {'end': 1597.858, 'text': 'so here 3 and 2.', 'start': 1595.656, 'duration': 2.202}, {'end': 1606.66, 'text': 'this would be the output right and the output of this display would be 10, 3, 2, 10, 3 and 2 right.', 'start': 1597.858, 'duration': 8.802}, {'end': 1610.423, 'text': 'so this is how we are going to implement stack using linked list.', 'start': 1606.66, 'duration': 3.763}, {'end': 1617.67, 'text': 'so in next video we will discuss some more applications of stack using code, as well as we will discuss about queue data structure.', 'start': 1610.423, 'duration': 7.247}, {'end': 1619.272, 'text': "right, so i'll see you in the next video.", 'start': 1617.67, 'duration': 1.602}, {'end': 1620.233, 'text': 'till then, bye, bye, take care.', 'start': 1619.272, 'duration': 0.961}], 'summary': 'The stack implementation output: 10, 3, 2.', 'duration': 49.343, 'max_score': 1570.89, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ1570890.jpg'}], 'start': 1338.976, 'title': 'Stack memory management and implementation', 'summary': 'Discusses memory management in a stack, emphasizing deallocation to prevent wastage and introduces underflow. it also explains implementing a stack using linked lists with push, pop, and display operations, demonstrated with elements 10, 3, and 2.', 'chapters': [{'end': 1435.658, 'start': 1338.976, 'title': 'Stack memory management', 'summary': 'Discusses the process of managing memory in a stack data structure, emphasizing the importance of deallocating memory to avoid resource wastage and introduces the concept of underflow condition.', 'duration': 96.682, 'highlights': ['Deallocating memory after popping from the stack Explains the necessity of cleaning up memory after popping from the stack to prevent resource wastage.', 'Use of free function to release memory Discusses the usage of the free function to release memory, emphasizing the importance of proper memory management.', 'Introduction of underflow condition in stack Introduces the concept of underflow condition in a stack and its significance in managing an empty stack.']}, {'end': 1620.233, 'start': 1435.998, 'title': 'Implementing stack using linked list', 'summary': 'Explains how to implement a stack using a linked list, including pushing and popping elements as well as displaying the stack content, with an example involving elements such as 10, 3, and 2.', 'duration': 184.235, 'highlights': ['The chapter explains how to implement a stack using a linked list, including pushing and popping elements as well as displaying the stack content, with an example involving elements such as 10, 3, and 2.', 'The output of the pop function would be 10, because we have deleted, we have printed this data, top data, now again, if you call peak, in that case it should print 3 only, because now, after popping one data, the topmost element is 3.', 'The output of the display function would be 10, 3, 2, 10, 3 and 2.']}], 'duration': 281.257, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/T_UXDTy23DQ/pics/T_UXDTy23DQ1338976.jpg', 'highlights': ['Deallocating memory after popping from the stack Explains the necessity of cleaning up memory after popping from the stack to prevent resource wastage.', 'Use of free function to release memory Discusses the usage of the free function to release memory, emphasizing the importance of proper memory management.', 'Introduction of underflow condition in stack Introduces the concept of underflow condition in a stack and its significance in managing an empty stack.', 'The chapter explains how to implement a stack using a linked list, including pushing and popping elements as well as displaying the stack content, with an example involving elements such as 10, 3, and 2.', 'The output of the pop function would be 10, because we have deleted, we have printed this data, top data, now again, if you call peak, in that case it should print 3 only, because now, after popping one data, the topmost element is 3.', 'The output of the display function would be 10, 3, 2, 10, 3 and 2.']}], 'highlights': ['The stack follows the LIFO (Last In, First Out) principle, and the implementation using a linked list is discussed, highlighting the operations of push and pop from the top of the stack.', 'The chapter also mentions the concept of singly linked list as the default linked list type, emphasizing the structure of a node within the list.', 'The linked list comprises two parts: the data part and the address part, with the latter containing the address of the next node (e.g., 400 and 100 in the given example).', 'The last node contains null, indicating it does not point to any other node, while the head pointer holds the address of the first node.', 'When programming a linked list, only the head pointer is initially available, serving as the address of the first node.', 'Using dynamic memory allocation in linked lists eliminates the need to specify stack size, providing a major advantage over arrays.', 'The malloc function is used for dynamic memory allocation, allowing the allocation of memory based on the size of the struct node, typically 8 bytes in size.', 'The chapter emphasizes the importance of checking for an underflow condition by verifying if the list is empty before attempting to display any data from the stack.', 'The explanation of the peek function illustrates how it displays the topmost element, in this case, accessing and printing the top element which is 10.', 'Deallocating memory after popping from the stack Explains the necessity of cleaning up memory after popping from the stack to prevent resource wastage.', 'Use of free function to release memory Discusses the usage of the free function to release memory, emphasizing the importance of proper memory management.', 'Introduction of underflow condition in stack Introduces the concept of underflow condition in a stack and its significance in managing an empty stack.']}