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

КОМЕНТАРІ • 62

  • @itsdineshvaryani
    @itsdineshvaryani  3 роки тому +2

    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

  • @amitpanc
    @amitpanc 5 років тому +15

    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 !!

  • @shubhamagarwal1434
    @shubhamagarwal1434 2 роки тому +2

    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 :)

  • @doggymama7553
    @doggymama7553 11 місяців тому +1

    Best Teacher For DSA , Thanks sir 🙏

  • @NeverGiveUpTryin
    @NeverGiveUpTryin 5 років тому +3

    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);
    }

  • @ashwiniv7053
    @ashwiniv7053 3 роки тому +2

    Thanks a lot Dinesh for awesome explanation.

  • @mustafakamalsirajudeen8133
    @mustafakamalsirajudeen8133 Рік тому +1

    Dinesh!!! Excellent tutorial. Real hard work man. Appreciate your efforts. Helped me a lot to understand Data Structure and Algorithms with real time examples.

  • @levsblinnikovs6209
    @levsblinnikovs6209 6 років тому +2

    Thank you very much, I understood a concept.

  • @AniketKumar-lv3td
    @AniketKumar-lv3td 3 роки тому +2

    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.

  • @soumyadipmajumder902
    @soumyadipmajumder902 Рік тому

    Easy to understand, awesome course

  • @charan_75
    @charan_75 3 роки тому +1

    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.

    • @itsdineshvaryani
      @itsdineshvaryani  3 роки тому

      doesnt matter !!! I believe it will still be garbage collected !!!

  • @pl5778
    @pl5778 6 років тому +3

    very very clear, awesome job!

  • @starlordgaming4765
    @starlordgaming4765 Рік тому +1

    You are great teacher

  • @samsonsafo8417
    @samsonsafo8417 2 роки тому +1

    That’s a really good explanation

  • @VINODG077
    @VINODG077 3 роки тому +1

    Very helpful series sir.🤗 Sir please make a playlist on collections framework.🙏

  • @neerajrawat6234
    @neerajrawat6234 3 роки тому +2

    sir stack element display kese karayenge

    • @itsdineshvaryani
      @itsdineshvaryani  3 роки тому +1

      Pop elements using pop() method and display ... Use while loop with condition !stack.isEmpty() - pop and print ...

  • @DolaLado
    @DolaLado 2 роки тому +1

    thank you.

  • @sanjushekhawat6446
    @sanjushekhawat6446 3 роки тому +1

    Keep it sir

  • @soumyadipmajumder902
    @soumyadipmajumder902 Рік тому

    Sir please a course on Linux OS

  • @mrinmoykalita5726
    @mrinmoykalita5726 Рік тому

    Sir I've a question why private ListNode are you using? Can't we use public

  • @samuel_william
    @samuel_william 2 роки тому

    What is the use of the constructor stack, by default top is null and length is 0 right

  • @jessenelson1437
    @jessenelson1437 3 роки тому +1

    great vid

  • @shantanum330
    @shantanum330 5 років тому +2

    what is the time complexity of this program?

  • @arijitmohapatra147
    @arijitmohapatra147 3 роки тому

    In pop operation won't we have to decrement top?

  • @ImranKhan-iu5sg
    @ImranKhan-iu5sg 4 роки тому +2

    about 1:50 you say top is pointing to null but i think you mean top = null

  • @jainababah6718
    @jainababah6718 10 місяців тому

  • @updates9126
    @updates9126 3 роки тому +1

    Is this the stack implementation using linked list sir?

  • @sanjushekhawat6446
    @sanjushekhawat6446 3 роки тому +1

    What difference linkeList araay nd stack

    • @itsdineshvaryani
      @itsdineshvaryani  3 роки тому +1

      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.

  • @abhaypratapsingh_life
    @abhaypratapsingh_life 5 років тому +2

    what if i write::
    private static Listnode top

    • @itsdineshvaryani
      @itsdineshvaryani  3 роки тому

      Nope !!! Don't do that !!!

    • @S__DhruvTrehan
      @S__DhruvTrehan 2 роки тому +1

      @@itsdineshvaryani is it necessary to use int method in creating the methods?Can we use the void method also?

    • @itsdineshvaryani
      @itsdineshvaryani  2 роки тому

      @@S__DhruvTrehan int method means it returns int value and void methods means it doesnt return anything ...

  • @vasudevparmar9876
    @vasudevparmar9876 3 роки тому +1

    can we print stack just like we did in linked list:- while(top!=null)and ..........

    • @itsdineshvaryani
      @itsdineshvaryani  3 роки тому

      Yes ... If u treat it as linked list

    • @vasudevparmar9876
      @vasudevparmar9876 3 роки тому

      @@itsdineshvaryani but it will give us infinite loop

    • @itsdineshvaryani
      @itsdineshvaryani  3 роки тому +1

      How ??? Infinite loop will be created when list's last node points back to top !!!

    • @vasudevparmar9876
      @vasudevparmar9876 3 роки тому +1

      one more help
      please provide link to download eclipse

    • @itsdineshvaryani
      @itsdineshvaryani  3 роки тому +1

      Just type eclipse downloads in google ... You will get link to eclipse site ... There u can download ide for java/jee

  • @joecamroberon9322
    @joecamroberon9322 5 років тому +1

    Wow, learning linked lists was so difficult compared to this.

  • @BilalMalik-tf2hr
    @BilalMalik-tf2hr 2 місяці тому

    .