How to implement a Stack using a Linked List in Java ? | Stack Data Structure
Вставка
- Опубліковано 19 вер 2024
- ►Full DSA Course - • Data Structures and Al...
►Follow me on Instagram - bit.ly/intrvwk...
►Follow me on LinkedIn - bit.ly/fllwlkdn
►Enroll in the complete course: bit.ly/3W4qthg
►Source Code - github.com/din...
►Download DSA Animation Slides - techready.in/c...
►Click here to subscribe - www.youtube.co...
Watch all my playlist here:
►Data Structures and Algorithms Course playlist: • Data Structures and Al...
►Mastering JUnit 5 - www.youtube.co...
►Mastering Mockito 3 - • Mockito 3 Tutorials
►Analysis of Algorithms - • Analysis of Algorithms
►Linked List Data Structures - • Linked List Data Struc...
►Array Data Structures - • Playlist
►Stack Data Structure - • Stack Data Structure
►Queue Data Structure - • Queue Data Structure
►Binary Tree Data Structure - • Binary Tree Data Struc...
►Graph Data Structure - • Graph Data Structure
►Binary Heap Data Structure - • Binary Heap Data Struc...
►Trie Data Structure - • Trie Data Structure
►Dynamic Programming Algorithms - • Dynamic Programming Al...
►Hashing Data Structures - • Hashing Data Structures
►Sorting and Searching - • Sorting and Searching
►String Algorithms - • String Algorithms
Want to land a software engineering job in the IT industry? This course - 'Visualizing Data Structures and Algorithms' is here to help. The course walks you through multiple Java algorithms, data structures problems, and their solutions with step by step visualizations, so that you are actually learning instead of blindly memorizing solutions.
The course covers in and outs of Data Structures and Algorithms in Java. Java is used as the programming language in the course. Students familiar with Javascript, Python, C#, C++, C, etc will also get to learn concepts without any difficulty. The implementation of various Algorithms and Data Structures have been demonstrated and implemented through animated slides. It covers many interview room questions on Algorithms and Data Structures. The questions and solutions are demonstrated by -
1. Animated slide. (To make visualization of algorithms faster)
2. Coding algorithm on IDE.
The course covers topics such as -
0. Algorithm Analysis
1. Arrays
2. Matrix
3. Singly Linked List
4. Doubly Linked List
5. Circular Singly Linked List
6. Stacks
7. Queues
8. Binary Tree
9. Binary Search Tree
10. Graphs
11. Priority Queues and Heaps
12. Recursion
13. Searching
14. Sorting
15. Strings
16. Trie Data Structure
17. Dynamic Programming
and many more ...
#dsa #algorithms #coding
Please *Like* , *Comment* , *Share* , *Subscribe* and *Click Bell* 🔔🔔🔔 Icon for More Updates. To get *Data Structures and Algorithms* complete course for free please follow this link - ua-cam.com/play/PL6Zs6LgrJj3tDXv8a_elC6eT_4R5gfX4d.html
I spent almost 2 hours looking for LL based implementation of stack. Yours was the only one that has explained in very simple manner. Too impressive way of teaching! Love from California !!
Welcome !!!
@@itsdineshvaryani can you upload trees and graphs implementation ?
Best series for DS & Algo. I am also 10 yrs java exp guy. Was looking for DS & Algo free course over UA-cam with java implementation and found this. Hats Off To You Man....Excellent Work. GOD BLESS YOU :)
Thanks !!!
Best Teacher For DSA , Thanks sir 🙏
Wonderfully explained and very easy to understand.
Anybody who is interested to see the full stack elements after push and pop operations use the below code and call printStack() method from the main method after push and pop operations:
public void printStack() {
if(isEmpty()) {
throw new EmptyStackException();
}
ListNode temp = top;
while(temp != null) {
System.out.print(temp.data + "->");
temp = temp.next;
}
System.out.println(temp);
}
thank you i was looking for this
Thanks a lot Dinesh for awesome explanation.
Welcome !!!
Dinesh!!! Excellent tutorial. Real hard work man. Appreciate your efforts. Helped me a lot to understand Data Structure and Algorithms with real time examples.
Welcome !!!
Thank you very much, I understood a concept.
Very clear explanation of data structure implementation that i ever saw
Thank you so much sir ❤️
One request please upload video on how to start competitive programming.
Thanks!!!
Easy to understand, awesome course
While using pop it is better to create a temp pointer referring to tops next node and make tops next node to null and then move top to temp. So Java garbage collector will be able to collect the removed object.
doesnt matter !!! I believe it will still be garbage collected !!!
very very clear, awesome job!
You are great teacher
Thanks
That’s a really good explanation
Thanks !!!
Very helpful series sir.🤗 Sir please make a playlist on collections framework.🙏
will see if i have time !!!
sir stack element display kese karayenge
Pop elements using pop() method and display ... Use while loop with condition !stack.isEmpty() - pop and print ...
thank you.
Welcome !!!
Keep it sir
Thanks !!!
Sir please a course on Linux OS
Sir I've a question why private ListNode are you using? Can't we use public
What is the use of the constructor stack, by default top is null and length is 0 right
great vid
Thanks !!!
what is the time complexity of this program?
O(1)
In pop operation won't we have to decrement top?
about 1:50 you say top is pointing to null but i think you mean top = null
yes
❤
Is this the stack implementation using linked list sir?
Yes !!!
What difference linkeList araay nd stack
Didnt get ur question. linkedlist is linear forming chains where nodes are referring to other nodes. Stack is a special data structure which is implemented via array or linkedlist. The last element inserted in stack is first to be removed. Array is indexed ds and elements are contiguous in memory.
what if i write::
private static Listnode top
Nope !!! Don't do that !!!
@@itsdineshvaryani is it necessary to use int method in creating the methods?Can we use the void method also?
@@S__DhruvTrehan int method means it returns int value and void methods means it doesnt return anything ...
can we print stack just like we did in linked list:- while(top!=null)and ..........
Yes ... If u treat it as linked list
@@itsdineshvaryani but it will give us infinite loop
How ??? Infinite loop will be created when list's last node points back to top !!!
one more help
please provide link to download eclipse
Just type eclipse downloads in google ... You will get link to eclipse site ... There u can download ide for java/jee
Wow, learning linked lists was so difficult compared to this.
Thanks !!!
.