What is STACK data structure in C++? What is LIFO? STL Stack explained in 14 mins! DATA STRUCTURES

Поделиться
HTML-код
  • Опубликовано: 17 июн 2024
  • 📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.
    Want to learn stack data structure in under 15 minutes? In this video, I'm explaining what is stack, how to work with the STL stack in C++, what are real-life examples of stack use, and more.
    You will also learn what is LIFO technique.
    A stack is a type of data structure that uses LIFO (Last In - First Out) technique to store elements. This means that new elements are added at one end (top) and elements can be removed from that end only.
    Other commonly used synonyms for the LIFO technique are FILO (First In - Last Out) and LCFS (Last Come - First Served)
    In this video, I'll also explain the five most important functions that you need to know if you want to work with stack data collections.
    Those are: empty, size, push, pop, top.
    ☕ If you've found my content helpful and would like to support me, you now have the option to buy me a coffee or a cookie! It's a small gesture of gratitude that means a lot to me and helps me keep creating free educational videos for you. Use the link to make a contribution: bit.ly/CodeBeauty_BuyMeACoffee
    However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇
    Contents:
    00:00 - Introduction
    00:20 - What is Stack? What is LIFO?
    01:30 - Example of stack use in real life
    02:51 - Functions used to work with stack
    03:46 - Implementation and working with STL Stack
    09:21 - How to write out elements of the stack
    Add me on:
    Instagram 📸 - / truecodebeauty
    Twitter 🐦- / truecodebeauty
    ******CODE IS IN THE COMMENTS******
  • НаукаНаука

Комментарии • 232

  • @CodeBeauty
    @CodeBeauty  3 года назад +43

    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.
    #include
    #include
    using namespace std;
    void printStackElements(stack stack) {
    while (!stack.empty()) {
    cout

    • @tyson3465
      @tyson3465 3 года назад

      Ma'am please keep uploading videos on DSA.

    • @GenjaOrigins
      @GenjaOrigins 3 года назад

      i like when u put all the code here not the code at the start :p it makes it easy to write it on my notepad with my pencil. It helps me remember stuff when needed.

  • @mdmobarokrubel2635
    @mdmobarokrubel2635 3 года назад +48

    More data structure, more algorithm stuffs we need Saldina. You rock

    • @GenjaOrigins
      @GenjaOrigins 3 года назад +2

      ye algorithms, data structures stl stuff and if someone can figure out solution to problems is what is required for interviews as junior also.

  • @jdkingsley6543
    @jdkingsley6543 3 года назад +11

    Love how you give us a real application example of stack. If you could do more that it be great. Sometimes trying to see c++ in action in software is hard to find.

  • @oussamabourouaiah6134
    @oussamabourouaiah6134 3 года назад +2

    I was having problems understanding stack memory in computer architecture course, and your explanation made everything clear. Thank you, really appreciate it.

  • @mohammadhawa337
    @mohammadhawa337 3 года назад +2

    Hello from Syria Saldine
    All thanks to you for the useful lessons you offer, with simple explanations.
    I hope you continue with the lessons of data structures and not delay with the lessons. Thank you.

  • @MonCarlo
    @MonCarlo 3 года назад +1

    love how you dissected the concept of LIFO and used actual examples

  • @wadalapichu4873
    @wadalapichu4873 2 года назад +1

    this was such a good explanation, it made something that a few hours ago ive seem as complicated to something way more simpler, also i liked that there was a camera, i think that using body language made it more digestible, thank you very much!!:)

  • @terenchosi1040
    @terenchosi1040 3 года назад +3

    Great video as always! Keep going!!

  • @dsiv08
    @dsiv08 3 года назад +3

    i passed my intro to c++ class with flying colors this term! can't wait for next term when we move on to more advanced topics :)

  • @user-tz1no1kv6u
    @user-tz1no1kv6u 3 года назад +2

    Here.. another informative lecture form you. Thanks very much every week!

  • @boyar3033
    @boyar3033 Год назад +1

    This is a crystal clear explanation. Thank you !

  • @heatherdouglas9493
    @heatherdouglas9493 Год назад +1

    Thank you for all of your time making clear and understandable lessons, they are extremely helpful and you have a wonderful way of conveying the subject you are teaching.

  • @tyson3465
    @tyson3465 3 года назад +3

    Very informative video for on DSA.
    Please continue uploading!

  • @guaicaipurouzumaki7654
    @guaicaipurouzumaki7654 2 года назад +1

    i saw other videos and i didn't understand anything, about stacks you make it very easy :) thank you!!

  • @emihernandez8784
    @emihernandez8784 3 года назад +2

    Beautiful and smart, what more could you ask for?
    Great video.

  • @ComputerGuru-tk2hg
    @ComputerGuru-tk2hg 7 месяцев назад +1

    The best code teacher, I understand c++ lot better now

  • @PinkSokka
    @PinkSokka 2 года назад +1

    Thanks for the simple and great explanation. My professor made this a lot more complicated.

  • @dimaferox5133
    @dimaferox5133 3 года назад +2

    oh STL, thanks! There are very useful and on the internet not really a lot of videos about STL.

  • @mereyjumabekova1471
    @mereyjumabekova1471 2 года назад +1

    Such a great content! Thank you it is really helpful, keep going! you are the best

  • @codebasic8558
    @codebasic8558 2 года назад

    Awesome video! After seeing this I will never pronounce parameter the same way :D. Keep the good content coming!

  • @shreyashpatil3728
    @shreyashpatil3728 Год назад +1

    Such a Great way to Explain Linked List . Thank you so much Mam. The Concept and Logic is Fully Cleared.

  • @edakimling133
    @edakimling133 3 года назад +1

    Nicely done. You speak very clearly and concisely. Easy to follow and I am sure novice programmers would learn from this. Cheers!
    If anything, a dark mode of your IDE would be very nice on the eyes (and us viewers). I don't know if VS supports it; I use open source editors and they all do...
    Nice to see more women in coding...

  • @WVBSSSID
    @WVBSSSID 3 года назад +3

    great content !!
    please upload more STL .
    Thank you ..

  • @joakim1745
    @joakim1745 2 года назад

    Thank you so much I needed this.You explained very well. Thank you

  • @_skyykim500
    @_skyykim500 3 года назад +5

    I dont know how to thank you seriously your lectures are amazing 😭😭
    Can you please make a video about different functions dealing with single & doubly linked list such as recursion, sorting, finding particular number, comparing linked list, modyfing linked list
    Its a humble request😭

  • @lucasfernandes5775
    @lucasfernandes5775 3 года назад +2

    great video !!

  • @nahiansharif4200
    @nahiansharif4200 2 года назад +1

    Wow, that was a great ecample of last in first out !

  • @anthonyhill9093
    @anthonyhill9093 Год назад

    Great explanations!

  • @sandipan17
    @sandipan17 2 года назад

    You really are "Code Beauty" 👌
    An amazing tutorial!

  • @lickguitars1276
    @lickguitars1276 2 месяца назад +1

    thanks for sharing, sharing to the world your personel experience is the greatest thing a teacher has good job love you💜💜

  • @mahmoud-khaled-abo-elmagd
    @mahmoud-khaled-abo-elmagd 3 года назад +1

    nice one
    waiting for queue and trees maps all data structure videos by you soon

  • @prabhathsannasooriya
    @prabhathsannasooriya Год назад +1

    wow it was amazing explaination. thumbs up

  • @hazel5835
    @hazel5835 2 года назад

    thanks! you explained it very well

  • @SavageScientist
    @SavageScientist 3 года назад +3

    Whoa the UNDO command is a great example of STACKS used in computer science

    • @joegongamer8637
      @joegongamer8637 2 года назад +1

      Something that I never thought of but I have thought of a good example of recursion which are taking a photo of yourself between two mirrors and screen recording/screenshotting your desktop through multiple windows.

    • @SavageScientist
      @SavageScientist 2 года назад

      @@joegongamer8637i created a video explaining all those concepts you just mentioned ruclips.net/video/v-xI-hAR_Us/видео.html

  • @mthandazonkomo1975
    @mthandazonkomo1975 Год назад

    Thank you so much for your great teaching of c++

  • @GlobStats
    @GlobStats 2 года назад

    thanks a lot miss Saldina well explained. mush appreciated.

  • @mrzaidivlogs
    @mrzaidivlogs 3 года назад +3

    Thanks for sharing such Valuable Content, That's Amazing!

    • @CodeBeauty
      @CodeBeauty  3 года назад +2

      You are so welcome!! 🤗🤗🧡

  • @husseinalim6916
    @husseinalim6916 3 года назад +1

    god bless you sister it's very important and i learn it very much

  • @abugslife2461
    @abugslife2461 Год назад

    thank you, you're awesome!

  • @johnpaulbancayrin6195
    @johnpaulbancayrin6195 3 года назад +8

    More videos about data structure ❤

  • @arjunsekarsd
    @arjunsekarsd 2 года назад

    Thank you so much for the info

  • @abdullahzahid8660
    @abdullahzahid8660 2 года назад

    you are the best teacher and beautifull person Thanks!!!

  • @wshacode7179
    @wshacode7179 2 года назад +1

    today in my university our lecturer talked about stack but I did not get anything from her, but after this video, i can say I am 100% understand your video now i am a (zoolly stack) in English means I am quite fully understand

  • @actor19927
    @actor19927 3 года назад

    Bravo Saldina, pozdrav iz Goražda 😘

  • @ZeroCool2211
    @ZeroCool2211 3 года назад +1

    Pls keep on uploading data structres tutorials

  • @klevialushi571
    @klevialushi571 3 года назад +3

    You should make a video related with Binary Trees too! So far I've enjoyed the data structures tutorials tho, keep it up!

  • @yusufrahimov9160
    @yusufrahimov9160 Год назад +1

    Thanks for videos

  • @yohansenurga4044
    @yohansenurga4044 3 года назад

    Wow, Saldina thank you.

  • @imrannabame4792
    @imrannabame4792 2 года назад +1

    omg! god bless you you have covered almost everything in one video.

  • @Calmalor
    @Calmalor 3 года назад +17

    Hello Saldina, Thank you a lot for your videos! They make learning programming really more enjoyable and I really appriciate the time you spending to make them. Actually I got one question about your study background. Did you also take Algorithms and Data Structures in your degree and could you maybe make a video about it, where you explain what the biggest challenges were for you and what tips and help you would have wished for before the module so that you could pass it successfully? It is just an idea because I am hearing from so many students they are struggeling about it. Best regards Tobias

    • @edakimling133
      @edakimling133 3 года назад +5

      Personally I always had trouble with Discreet Mathematics...that was tough. Data Structures was easy, as you get to use practical examples and it just makes sense. Discreet Math - very useful but hard to grasp :)

  • @sslvsme5763
    @sslvsme5763 7 месяцев назад

    cool video, I don't really find it hard to learn the algorithms through description on leetcode although I'm a beginner but when I search for the detailed explanations on youtube or anywhere else for code implementation its an indian gargling or someone just saying nonsense that makes it harder to understand even though I already understood it. Understanding the problems is quite easy for me but what to code is harder since I don't know all my stuff I am nub. This video is fantastic, I solved an leetcode question only related by topic to stacks with it in C++ which I barely know anything about. Thanks for showing me how to use C++

  • @adelinbonheurnsengiyumva5546
    @adelinbonheurnsengiyumva5546 2 года назад +1

    Thanks Ma'am!

  • @nomannoman2492
    @nomannoman2492 3 года назад +2

    Thank You ❤️

  • @bizio12
    @bizio12 3 года назад +1

    Always clear.. Thx

    • @joegongamer8637
      @joegongamer8637 2 года назад

      Something I do appreciate and could agree on but somebody's gotta step in when she can't answer all of the computer programming questions the viewers have.

  • @mahadevsai3748
    @mahadevsai3748 3 года назад +1

    Mam, ur explanation is superb 👌🏻👏.......pls make videos on DP, BST ,GRAPHS,some complex concepts...................it will help us a lot....tq mam

  • @mejmanat4845
    @mejmanat4845 3 года назад

    Good video, thanks

  • @sonalibachhav9229
    @sonalibachhav9229 3 года назад +1

    Ohhh God
    How can i tell you this video is amazing
    you are too good

  • @vimbichiradza5155
    @vimbichiradza5155 Год назад +1

    She is the best ❤

  • @hmd2372
    @hmd2372 6 месяцев назад

    Clear usefull thank u

  • @cheetahalpha4648
    @cheetahalpha4648 3 года назад +3

    Your videos really help ma a lot

    • @CodeBeauty
      @CodeBeauty  3 года назад +1

      I'm happy to help! 🧡🤗

  • @cheetahalpha4648
    @cheetahalpha4648 3 года назад +2

    Thanks

  • @conceptwithayan4737
    @conceptwithayan4737 Год назад +1

    how explain very well❤

  • @cabdiraxmaankhaliiftahliil9217
    @cabdiraxmaankhaliiftahliil9217 3 года назад +1

    Really helped me alot
    But doing more lessons about data structure

  • @AlaniHill
    @AlaniHill 2 года назад

    Beautiful and great teacher , u got my sub and like

  • @krishsharma6276
    @krishsharma6276 3 года назад +1

    You are just osm yaar 👍🤘

  • @vagifasadov3128
    @vagifasadov3128 Год назад +1

    Thank you for explaining all of this stuff,. Would you please continue with Data Structures and Algorithms with C++ series?
    You are so helpful.

  • @zainulabideen5595
    @zainulabideen5595 Год назад

    Keep it up ☺️

  • @safaamaz
    @safaamaz Год назад

    thanks you mrs

  • @danny12345
    @danny12345 3 года назад +1

    Thanks for the great lessons. Is it possible to ask if you can give a lesson in class and header and the connection white the main class.

  • @mmaranta785
    @mmaranta785 3 года назад +1

    Very clear explanation

  • @syncwithnature73
    @syncwithnature73 Год назад +1

    I will definitely subscribe to your channel I want to learn a lot from you, you make people understand easily

  • @animeshpandey1331
    @animeshpandey1331 3 года назад

    please make a vedio covering all the data structures and thank you so much for your vedios.

  • @joborfrederick4312
    @joborfrederick4312 2 года назад

    Thank you Salina 🥺

  • @johnsknows3135
    @johnsknows3135 Год назад

    thank you

  • @moularaoul643
    @moularaoul643 3 года назад +2

    Thanks again and again !!!

  • @philtoa334
    @philtoa334 3 года назад +2

    Thank you.

  • @thetypicalone2525
    @thetypicalone2525 2 года назад

    Please make full playlist on data structures and algorithms with every variation that exists 🙏🙏🙏🙏😍😍😍😍😍👍

  • @khalidessamoudi2291
    @khalidessamoudi2291 3 года назад +1

    Thanks a lot
    Please can you provide more deep

  • @roros2512
    @roros2512 3 года назад +4

    after linked lists with ptrs, this is a lot less hard, thanks Saldina!

    • @bearsoundzMusic
      @bearsoundzMusic 2 года назад

      and yet those lists was only singleton linked, and had no iterators. Add those, and lists are suddenly even harder, and _then_ stacks are childsplay

    • @roros2512
      @roros2512 2 года назад

      @@bearsoundzMusic why broke my dreams

  • @bagaspermana88
    @bagaspermana88 2 года назад

    thanks

  • @alexandruteodor3585
    @alexandruteodor3585 3 года назад +1

    Hi, Saldina! I have to solve many problems with arrays of strings in C++ and I don't quite understand them. Would you like to make a tutorial about them, please?

  • @rishabjain6452
    @rishabjain6452 3 года назад +2

    C++ has a header file for Stack functions?
    Neat!
    C was a disaster

  • @quanm7077
    @quanm7077 2 года назад

    thanks

  • @ahmadmohamad8416
    @ahmadmohamad8416 2 года назад

    ty

  • @suleymankocamaz3743
    @suleymankocamaz3743 3 года назад +1

    can you make more video cuz ı like it and need it

  • @brandongregory7576
    @brandongregory7576 2 года назад

    Is there a way I can see your headerfile that holds eveything in stacknumberStacks? I would like to see how you set up things like pop push top

    • @brandongregory7576
      @brandongregory7576 2 года назад

      Never mind, I didnt realize that the functions were all included in the stack and you just needed to call them. Thank you for the video

  • @kevinz1991
    @kevinz1991 3 года назад +2

    so helpful thanks saldina

    • @CodeBeauty
      @CodeBeauty  3 года назад +1

      Kevin you're welcome! 🤗

    • @kevinz1991
      @kevinz1991 3 года назад +1

      curious why we dont have to use reference operator (&) when we pass "stack stack" to printStackElements() if anyone sees this and wants to lecture me lol

    • @joegongamer8637
      @joegongamer8637 2 года назад

      @@kevinz1991 I'm not sure. Maybe it's because classes and objects uses something like this->attribute instead of this.attribute? Whereas regular variables aren't automatically referenced? I'm sorta confused about it too.
      What I know for sure is the stack elements were never modified in the function she created. Her function probably took a copy of the original stack from the main method.

  • @chibuezekennedy3127
    @chibuezekennedy3127 3 года назад +2

    You are simply the best😍🥰😘

    • @CodeBeauty
      @CodeBeauty  3 года назад +1

      Thank you so much! 🧡🤗

    • @chibuezekennedy3127
      @chibuezekennedy3127 3 года назад

      @@CodeBeauty am looking forward for a full course on data structure and algorithm in c++🙂
      Thanks in advance ☺

  • @tanny_edits
    @tanny_edits Год назад

    13:13 my answer is 2, 1 cause stack is last in first out, the last element we inserted is 3 therefore it will be the first element that will be removed when we perform the pop function

  • @tonyx8613
    @tonyx8613 3 года назад +5

    I have always been interested in knowing how the stack and heap work in programming but with a hardware reference approach. What are the advantages or disadvantages of hosting information on the stack or heap?

    • @antonmakeyenko4018
      @antonmakeyenko4018 3 года назад +2

      In short:
      1. Stack is used for storing of local variables. Pros: easy to push (just increase stack pointer (esp register) to the amount of bytes needed); freed automatically when function returns (in function epilogue) => object's destructor is called as soon as local variable goes out of scope; Cons: relatively small => stack overflow exception when there is no enough memory
      2. Heap is used for "long-lived" variables in most cases. Pros: huge size; Cons: slower, because to allocate memory allocator has to find an empty block of memory; allocation/deallocation has to be done manually: new/delete, malloc/free => quite easy to get memory leak

  • @yuwang6469
    @yuwang6469 Год назад

    Great content! Just have one question. Could you make some explanation why `pop` of `printStackElements` didn't pop out elements as line 18? Thanks

  • @nidzeksmocni659
    @nidzeksmocni659 3 года назад

    Saldina je l si iz Bosne? Hvala ti mnogo na videima! Samo napred lutko!

  • @eenugaming
    @eenugaming 3 года назад +2

    Please make a tutorial on how to make a program that reads data from text file

  • @joegongamer8637
    @joegongamer8637 2 года назад

    I like to think of the rule of stacks like *F*irst In *L*ast out. First in as in the first element gets into the stack. Last out as in the most recent element that has entered the stack gets out of the stack first. As long as our different interpretations have the same meaning, then I'd say I'm not far away from its definition.

  • @i.sapnadip
    @i.sapnadip 2 года назад

    Keep posting plzzzzzzzz

  • @user-td4pf6rr2t
    @user-td4pf6rr2t Месяц назад

    last in first out. meaning that the most recent input is on the top of stack when reading left to right and top to bottom.

  • @zahidsadiq1251
    @zahidsadiq1251 Месяц назад

    Outclass mam love from Pakistan 🇵🇰

  • @manoharsagunthalla9215
    @manoharsagunthalla9215 3 года назад +2

    The elements avail in stack is 1 2

  • @1conscience0dimension
    @1conscience0dimension 3 года назад

    ok this is well explained, even if sometimes you could jump some details. an example where it is put into practice would be useful.

    • @1conscience0dimension
      @1conscience0dimension 3 года назад

      #include
      #include
      typedef unsigned long long int XXL; //predefined type, used for visibility
      using namespace std;
      int main(){
      cout

  • @adroaldoferreira978
    @adroaldoferreira978 3 года назад +1

    Thank you so much. How to print reverse order of elements?

    • @joegongamer8637
      @joegongamer8637 2 года назад

      That's a good question. The rules of the stack only lets you access the top element, which makes accessing any elements less flexible. I'd say arrays have a good flexibility of accessing elements since there's no "strict" rule of how to access them. So, to print the reverse order of the elements from the stack, the only way I can think of is to transfer the stack elements into an array. Use a for loop to have this array print its elements from the last index to the first index. Of course, you can have this strat in a function. Hope that helps.