Linked List Implementation of Stacks (Part 2)

  Рет қаралды 132,443

Neso Academy

Neso Academy

Күн бұрын

Пікірлер: 46
@studyareaat-ep1dt
@studyareaat-ep1dt 9 ай бұрын
Your are the best teacher in this world ❤❤❤❤❤❤❤
@Error-gc1rr
@Error-gc1rr 3 жыл бұрын
I have learnt so much and with daily practice, I am getting really good at programming. Thanks for every thing you have done Neso Academy
@RedMasterMorphiX
@RedMasterMorphiX 2 жыл бұрын
Sir we really Need a teacher like you in our university. Such a beautiful representation and teaching. All my Doubts got cleared . Thank you so so much. And finally I will be able to attend my final exam tomorrow
@Reetesh644
@Reetesh644 3 жыл бұрын
Best teacher ever ❤️❤️
@dipeshsamrawat7957
@dipeshsamrawat7957 3 жыл бұрын
I love Neso Academy. 💝
@divyanshi7178
@divyanshi7178 Жыл бұрын
the best ever explanation, gone through many videos of different channels but this one has cleared all my doubts, thank you sir
@Randomx760
@Randomx760 3 ай бұрын
The lecture covers the linked list implementation of stacks, focusing on the node structure and the push function. It explains creating a new node, updating pointers, and handling memory allocation. The final part demonstrates the complete code implementation and user interaction for pushing and printing stack elements. Highlights: 00:06 This lecture focuses on the linked list implementation of stacks, emphasizing the structure of nodes and the use of a top pointer instead of a top variable. Understanding these concepts is crucial for effective stack operations in C programming. -The push function code is critical for adding elements to the stack, ensuring that the linked list structure is maintained as elements are added. This function manipulates the top pointer. -The structure of the node is essential for representing elements in the stack, consisting of data and a link to the next node. This follows the singly linked list format. -Declaring a top pointer globally allows for easy access to the first node in the linked list, which is necessary for stack operations. This approach replaces the traditional top variable used in arrays. 02:25 The video explains how to implement a stack using a linked list in programming. It specifically focuses on the structure of nodes and the push function. -The structure of a node is crucial for creating a stack. The top pointer must be initialized to null, indicating an empty stack initially. -The push function for the stack is analogous to the add back function in singly linked lists. Small modifications are made to adapt it for stack operations. -When pushing a new element onto the stack, a new node with the corresponding value is added to the top. This ensures the stack's Last In First Out (LIFO) behavior. 04:43 Creating a new node in a linked list involves allocating memory and updating pointers. The new node's link must point to the current head of the list. -The first step in creating a new node is to allocate memory using the malloc function. This ensures that the new node has a designated space in memory. -After memory allocation, it's essential to set the data for the new node. In this case, the data is set to 50 before linking it to the list. -The link part of the new node must be updated to point to the existing first node. This is done using the top pointer to access that node's address. 07:02 The final step in implementing a stack's push function is to update the top pointer to point to the newly added node in the linked list. This ensures that the topmost element is always accessible for future operations. -Memory allocation is critical when creating a new node, as it uses the malloc function. If malloc returns null, it indicates a stack overflow due to insufficient memory. -An important check in the push function is to ensure that the new node is not null. This step prevents abnormal program termination due to stack overflow. -The push function is designed to add elements without returning any value, which is why its return type is void. This design simplifies the function's implementation within the stack structure. 09:21 The video demonstrates how to implement a simple stack using a linked list in C programming. It covers pushing, printing, and quitting operations in a user-interactive console application. -A temporary pointer is created to traverse and print elements of the linked list. This allows for easy access to each node's data until reaching the end. -The user is prompted to enter choices for stack operations, including pushing an element, printing the stack, or quitting the program. A switch case manages these user inputs effectively. -The stack's current elements are displayed after pushing new values, showing the last pushed element as the topmost. This demonstrates the Last In First Out (LIFO) property of stacks.
@eagiepal3470
@eagiepal3470 3 жыл бұрын
Damn i barely can't understand my prof. explaining but in your video its easy. printf("Thanks Bro!");
@monicabattacharya6416
@monicabattacharya6416 3 жыл бұрын
please complete this course fastly because there were queues , trees and graphs 📊😀 to complete. THEY MAY TAKE MORE TIME
@vengalrao5772
@vengalrao5772 2 жыл бұрын
@encode decode hello bro where u have completed ? I need to learn !
@wog4299
@wog4299 2 жыл бұрын
@@vengalrao5772 where you learnt other topics ?
@vengalrao5772
@vengalrao5772 2 жыл бұрын
I have skipped for nearly 2 months... Started since 10 days.. after that I feel code with Harry , mycode champ school... I can find the best
@vengalrao5772
@vengalrao5772 2 жыл бұрын
@@wog4299 lemme know if any good resources !
@parvahuja7618
@parvahuja7618 2 жыл бұрын
thanks to neso academy i am liking dsa again
@proadvices8592
@proadvices8592 Жыл бұрын
Thanks sir... I appreciate your work and time that u are giving too us really your way of teaching is really very nice... Thanks a lot...❤
@progos1485
@progos1485 2 жыл бұрын
Thank you so much sir. ❤
@gusionfusion1073
@gusionfusion1073 3 жыл бұрын
while using malloc at 5:38 shouldnt we write = malloc (sizeof(struct node)) ????? intead of malloc(sizeof(newNode))
@joegonzalez7434
@joegonzalez7434 3 жыл бұрын
You bring up a good point. malloc (sizeof(newNode)) would dynamically create memory the size of the node pointer. malloc (sizeof(struct node)) would dynamically create memory the size of the node itself. I think the latter is the way to go. It doesn't make sense why we are allocating memory the size of the node pointer and not the actual node. Hope someone can chime in on this some more.
@AbhinavKumar-qv7to
@AbhinavKumar-qv7to 2 жыл бұрын
@@joegonzalez7434 yes, its a mistake. It should be struct node as newnode is a pointer to the node.
@tusharkumar2077
@tusharkumar2077 2 жыл бұрын
@@joegonzalez7434 I think that newnode pointer might allocate the size of structure node because that pointe is just use for referring to the struct node so malloc will allocate the memory by reference
@tusharkumar2077
@tusharkumar2077 2 жыл бұрын
@@AbhinavKumar-qv7to think that newnode pointer might allocate the size of structure node because that pointe is just use for referring to the struct node so malloc will allocate the memory by reference
@Aditya_Ramakrishna21
@Aditya_Ramakrishna21 4 ай бұрын
I had the same doubt
@suchithkumargm
@suchithkumargm 2 жыл бұрын
Sir can u continue this series with queue tree and graphs It's helping us a lot
@黃-i9h
@黃-i9h Жыл бұрын
Thank you so much!! I finally figured it out!
@progos1485
@progos1485 2 жыл бұрын
Really amazing👍😍😍
@nicoleshi5013
@nicoleshi5013 7 ай бұрын
Why do we have to put the newNode->link = NULL? Why not just newNode->link = top?
@samadhanpol7239
@samadhanpol7239 2 жыл бұрын
Nice presentation sir
@MrriamAddel
@MrriamAddel 2 ай бұрын
Thank you 🤍🤍🤍
@Mr_Memer01_
@Mr_Memer01_ Жыл бұрын
Please make a video on quick Sort in DSA Please sir💯
@BhargavGajjala-x2p
@BhargavGajjala-x2p Жыл бұрын
Here also we are trying to change the top pointer and that change should be local to push function same as we discused in add beg function in linked list then how it is updating the top in pop function
@estelle9819
@estelle9819 3 жыл бұрын
thank you so much for this
@Tech_BourA
@Tech_BourA 10 ай бұрын
Thanks for this explanation but I think there is a mistake in the complete function of push operation 7:35, you are missing the parameter "struct node **top" in the declaration, it should be "void push (int data, struct node **top)" instead of "void push (int data)" Correct if I am wrong, thank you.
@abhiraj2005
@abhiraj2005 4 ай бұрын
you are wrong my friend, since the top pointer is globally declared, you need not to pass anything inside the parameter.
@abdelkaremhomidi7322
@abdelkaremhomidi7322 Жыл бұрын
THANK YOU SO MUCH
@tentohari
@tentohari Жыл бұрын
your awesome
@zainshah804
@zainshah804 2 ай бұрын
Where can i get that code
@abhishekmahor6700
@abhishekmahor6700 2 жыл бұрын
I am hungry sir I want more content of data structure lite tree, graph.
@rajeshprajapati4863
@rajeshprajapati4863 3 жыл бұрын
❤️❤️❤️
@harshithashetty233
@harshithashetty233 2 жыл бұрын
Can u make a video about implementation of queue using linked list
@VikasKumar-tt8dz
@VikasKumar-tt8dz 3 жыл бұрын
please complete the course asap....it is fun to learn🙂🙂🙂
@sujansasmal6657
@sujansasmal6657 Жыл бұрын
How can you perform push operation without creating a stack?
@ramya8669
@ramya8669 2 жыл бұрын
The print function is not working my system
@raomubashir3976
@raomubashir3976 2 жыл бұрын
I am getting error at malloc line the compiler showing error that a value of type"void"can't be assigned to an entity of type "node"
@joyatidas1016
@joyatidas1016 2 жыл бұрын
requires type casting to structure type.
@smrpkrl
@smrpkrl Жыл бұрын
5:08
@sagnikkayal782
@sagnikkayal782 2 жыл бұрын
but rather than a separate pointer 'top' ,why can't we just rename the 'head' pointer as 'top' ?
Linked List Implementation of Stacks (Part 3)
11:46
Neso Academy
Рет қаралды 76 М.
3.3 Stack implementation using Linked List | Data Structures and Algorithm Tutorials
27:01
ССЫЛКА НА ИГРУ В КОММЕНТАХ #shorts
0:36
Паша Осадчий
Рет қаралды 8 МЛН
Ozoda - Alamlar (Official Video 2023)
6:22
Ozoda Official
Рет қаралды 10 МЛН
Wednesday VS Enid: Who is The Best Mommy? #shorts
0:14
Troom Oki Toki
Рет қаралды 50 МЛН
Linked List Implementation of Stacks (Part 1)
9:24
Neso Academy
Рет қаралды 250 М.
Stacks using linked list
19:23
Sudhakar Atchala
Рет қаралды 16 М.
8 Data Structures Every Programmer Should Know
17:09
ForrestKnight
Рет қаралды 245 М.
Queue Implementation using Arrays
13:46
take U forward
Рет қаралды 135 М.
you will never ask about pointers again after watching this video
8:03
Data Structures: Linked List implementation of stacks
10:58
mycodeschool
Рет қаралды 641 М.
Array Implementation of Stacks (Part 1)
10:00
Neso Academy
Рет қаралды 398 М.
The Dark Side of .reserve()
18:50
Logan Smith
Рет қаралды 161 М.
Rust Functions Are Weird (But Be Glad)
19:52
Logan Smith
Рет қаралды 148 М.
ССЫЛКА НА ИГРУ В КОММЕНТАХ #shorts
0:36
Паша Осадчий
Рет қаралды 8 МЛН