Introduction to Stacks and Queues (Data Structures & Algorithms #12)

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

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

  • @thesheepthemightythecrazy
    @thesheepthemightythecrazy 4 года назад +247

    RUclips really should recommend this channel to more young ppl.

  • @MinecraftJesusGaming
    @MinecraftJesusGaming 4 года назад +96

    This man is a legend. I took Data Structures over the summer and forgot everything. This man helps me remember stuff

  • @nick_jacob
    @nick_jacob 2 года назад +47

    Very easy to understand. Would like to see some coding examples too but this is nice. I have been a developer for 6 years and i'm just now getting into data structures. However i'm realizing that i've basically been using them all along without knowing it.

    • @elijohn8114
      @elijohn8114 Год назад +5

      i use this channel and codebeauty. this one gives me an awsome overview whille codebeauty explains it with coding she uses c++

  • @abdullahbukhari1469
    @abdullahbukhari1469 4 года назад +45

    Love you brother, the best ex-Google/Facebook employee on RUclips

  • @virathshuklla172
    @virathshuklla172 4 года назад +16

    I was waiting for this video for a lot of time. This channel is best for Python I highly recommend it to my friends.
    Great Y.K.

  • @lancepaulino1303
    @lancepaulino1303 3 года назад +6

    Imagine if your professor teaches like this and add up those simple analogies so their students will have an easier approach to grasp the lesson at hand..... anyways, thank you so much for your precious videos!

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

    I have loved the quarantine life learning programming 24*7

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

    Great video..you got it right a Deque is actually called a "Deck" or Double Ended Queue so many people get it wrong an call it a "De Que" then get it confused with Enque/Deque.

  • @刘生-o9b
    @刘生-o9b 3 года назад +3

    感谢你的分享,让我学习了很多知识,谢谢。

  • @azimmirzoev6704
    @azimmirzoev6704 3 года назад +14

    I am CS student, and I have been following your channel for almost 2 years. It's a great explanation, but it would be more useful and more interesting if you could also show your explanation in code! Anyways thank you for your efforts!

  • @unitydeveloperkgk9836
    @unitydeveloperkgk9836 2 года назад +13

    These videos are great and the visuals help a lot. The black background in your videos seems to improve memory recall for some reason as opposed to a white background. Its easier to visualize what I saw from your videos, than others because of this and it does not burn your retinas out while watching them either lol.

  • @jeppirukun2546
    @jeppirukun2546 4 года назад +30

    I really struggle on my studies on Computer Science, and I still want it to become successful in this path. Please help me sensei.

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

      keep learning for a few decades that is the only way of becoming good at something

    • @sihyunpark6245
      @sihyunpark6245 3 года назад +6

      @@emanuelriquelmemontoya3819 Though you are right, if it doesn't come naturally to you even when taught over and over then you should consider choosing a different path, not everyone is made to do one thing we all have a strength and weaknesses.

  • @udaysinh
    @udaysinh 4 года назад +1

    It is really nice to learn this at age of 15 and good explanation...thank you

  • @Shortstories__100
    @Shortstories__100 4 года назад +19

    I have watched almost all of your videos they are very helpful.
    Can you start a series on JavaScript . Love your videos bro

    • @CSDojo
      @CSDojo  4 года назад +9

      Not sure if I can do an entire series, but I'm thinking of making a Chrome extension with JS at some point. Thanks for letting me know your thoughts anyway!

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

    Phew....I finally understood the gibberish my class was teaching

  • @Perres21
    @Perres21 4 дня назад

    Wow thank you. Its so easy to understand with this video

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

    That octopus looks real busy. Good work explaining this.

  • @GhostVaibhav
    @GhostVaibhav 4 года назад +8

    Bro, you just nailed the explanation part!!! Keep up the good work!!❤️❤️

  • @prathamesh_b
    @prathamesh_b 4 года назад

    @CS Dojo
    Thankyou Sir for guiding us!

  • @leonardourbanavicius
    @leonardourbanavicius 4 года назад +2

    I did a twitter bot with your video and stayed very happy!!! Hope this bot I made can help people to be happier, it spreads positive messages! thanks again!

    • @CSDojo
      @CSDojo  4 года назад +2

      That sounds great! Thank you for letting me know :)

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

      can u share what vedios did u use

  • @sahelijati5851
    @sahelijati5851 4 года назад +1

    finally found a good programming teacher..

  • @eyalpery8470
    @eyalpery8470 3 года назад +7

    "This is how pancakes in the real world work"
    Legendary!

  • @manuelelkess8259
    @manuelelkess8259 4 года назад +1

    your videos help me a lot thank you and please continue this course until the very end

  • @garvitpahwa2349
    @garvitpahwa2349 4 года назад +2

    You are the best pls keep uploading. Love from India

    • @CSDojo
      @CSDojo  4 года назад +2

      Yes I will!

  • @Elif-ti9wf
    @Elif-ti9wf 4 года назад +5

    Aaaaah this week I took the first lesson of the data structures course at school thank you 🤗

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

    I was just stuck on that problem at the end, thanks!

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

    You are very good at explaining stuff. It would have great if we could watch at some code example as well, simple ones.

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

    Favorite quote: "That's how pancakes in the real world work."

  • @margaritashielatimbal638
    @margaritashielatimbal638 4 года назад +2

    I just had a quiz on this subject and our topic was stack. This video was really helpful. Hopefully, you'll make a series about C or C++

  • @Alex-bc3tt
    @Alex-bc3tt 3 года назад +2

    I liked the video just after playing it... and when I was done I wished I could like it again... thanks for the great content you never disappoint

  • @maxxpellowski2916
    @maxxpellowski2916 3 года назад +7

    Another great video YK, thank you. I may not know much about data structures, but I know pancakes and you really break it down wonderfully. 🤣

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

    How have I not found this channel before now?

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

    Straightforward analogy. But what's an example of a use case for stacks and queues? In what type of scenario would I need to use a stack?

  • @mohammadyasir8700
    @mohammadyasir8700 4 года назад +7

    You are AWESOME !! , you should interact with us by uploading videos on various topics !!!

    • @CSDojo
      @CSDojo  4 года назад +2

      I will!

  • @bjarneStroustrup350
    @bjarneStroustrup350 4 года назад

    Best explanation for DS❤️😘🇮🇳

  • @lucyledezma709
    @lucyledezma709 4 года назад

    Hello Cs Dojo!!!. So much time again!!!

    • @CSDojo
      @CSDojo  4 года назад +1

      Hello, and sorry! I'll be faster :)

  • @gayatrit3149
    @gayatrit3149 4 года назад +2

    I thought you stopped making videos, thank god your back , have learnt a lot from you , Thanks a lot !!!!!

  • @krzysztofkalinowski2998
    @krzysztofkalinowski2998 9 месяцев назад +1

    Here is my Deque class (in java) if someone needs example
    public class CustomDeque {
    private Integer[] dequeArray;
    private int count;
    private int max;
    private int leftIndex;
    private int rightIndex;
    public CustomDeque(int length) {
    dequeArray = new Integer[length]; //this array can be int if you don't need to store null values
    count = 0;
    max = length;
    leftIndex = 0;
    rightIndex = 1;
    }
    public void addLeft(int data) {
    if (count >= max) {
    System.out.println("Deque is full");
    return;
    }
    dequeArray[leftIndex--] = data;
    leftIndex = indexBounds(leftIndex);
    count++;
    }
    public void addRight(int data) {
    if (count >= max) {
    System.out.println("Deque is full");
    return;
    }
    dequeArray[rightIndex++] = data;
    rightIndex = indexBounds(rightIndex);
    count++;
    }
    public Integer popLeft() {
    if (count == 0) {
    System.out.println("Deque is empty");
    return null;
    }
    leftIndex = indexBounds(++leftIndex);
    count--;
    int result = dequeArray[leftIndex];
    //no need to empty values. Its enough to just move indices. This is purely to debug using toString() method
    dequeArray[leftIndex] = null;
    return result;
    }
    public Integer popRight() {
    if (count == 0) {
    System.out.println("Deque is empty");
    return null;
    }
    rightIndex = indexBounds(--rightIndex);
    count--;
    int result = dequeArray[rightIndex];
    //no need to empty values. Its enough to just move indices. This is purely to debug using toString() method
    dequeArray[rightIndex] = null;
    return result;
    }
    private int indexBounds(int index) {
    if (index < 0) return dequeArray.length - 1;
    if (index > dequeArray.length - 1) return 0;
    return index;
    }
    @Override
    public String toString() {
    return "[CustomDeque] = leftIndex = " + leftIndex + "; rightIndex = " + rightIndex + "; dequeArray = " + Arrays.toString(dequeArray);
    }
    }

  • @manu-singh
    @manu-singh 4 года назад +2

    Your videos are getting rarer to get hold of.

    • @CSDojo
      @CSDojo  4 года назад +1

      Sorry about that - I'll start posting more from now on

    • @manu-singh
      @manu-singh 4 года назад +1

      @@CSDojo don't be sorry, I am sure you're probably busy at work.
      I learned so much from your interview problems and this DSA playlist.
      So thank you for that.

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

    THIS VIDEO IS SO GOOD

  • @DarthVader-wm6tf
    @DarthVader-wm6tf 4 года назад +1

    Yeah ... You're back ... Horrah .. so happy you're back ... Cheers for yk

  • @NikhilKumar-fj2dg
    @NikhilKumar-fj2dg 4 года назад +1

    This is what I'm waiting for Thankyou so much 🔥👍🙏

  • @CorwinBell
    @CorwinBell 2 месяца назад

    Curious why you use an array to hold your stack? Wouldn't a linked-list make more sense since it already has stack methods (e.g. push and pop)? You even mention that if you run out of space with your array you'd have to create a new array, one of its key limitations. I also find moving the pointer reference to a different index while keeping the value in place instead of actually popping the value to be an awkward representation of popping the top value of the stack

  • @selvalakshmis.v4232
    @selvalakshmis.v4232 3 года назад

    This video is really helpful for me Thank you.

  • @cowsofliberty5230
    @cowsofliberty5230 5 месяцев назад

    csdojo you the boy

  • @nayanasagar6062
    @nayanasagar6062 4 года назад

    Can u please upload videos on regular basis......The way u guide through is really amazing...a sincere request ...🙏

    • @CSDojo
      @CSDojo  4 года назад +2

      I'll try my best. Thank you!

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

    my friend says he likes your sweater; keep it up man! :)

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

    If I have a queue, and it's a tasks queue, once that one task is completed I should remove the element from the queue, or just move the pointers?
    And if I should just move the pointers, once that the pointers are on its limits, I would have to create another bigger queue to do what I want, right? This approach wouldn't use a lot of memory?
    Once I made this remark, am I right if I define a queue as something that should be just a collection of things that will be freed of the memory soon, once it's completed?
    Edit1: I was searching about, and one good response that I found was to use linked-lists, what I think is a great approach, once that it is first-in first-out, so you wouldn't have the problem of needing to change something or access something in the middle of the list, at least I think so.
    Edit2: @t
    Here's the code I've developed so far, trying to solve this issue.

  • @KilluaZoldyck-wj5cy
    @KilluaZoldyck-wj5cy 4 года назад +4

    Finally you remembered you have a RUclips channel 😂😂😂. Awesome explanation btw👍🔥

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

      Haha yes, sorry about the delay - but I'll post more

    • @Abdullah-cp6eb
      @Abdullah-cp6eb 4 года назад +1

      @@CSDojo no prpblem Dojo we will wait till die
      That was ridiculous righto😀

    • @KilluaZoldyck-wj5cy
      @KilluaZoldyck-wj5cy 4 года назад

      @@CSDojo I'm waiting 😄. By the way I want to buy a laptop for college......Got any recommendations?

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

      @@KilluaZoldyck-wj5cy im replying very late but i would recommend Dell XPS

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

    Brilliant explanation, thank you

  • @souhardya69
    @souhardya69 4 года назад

    After a long wait.. Welcome back

    • @CSDojo
      @CSDojo  4 года назад +1

      Sorry for the wait! I'll try to be faster in the future.

  • @tushig.b.6526
    @tushig.b.6526 3 года назад

    You are the life saver! Hontouni arigatou gozaimasu!

  • @kartikbilagiarts7213
    @kartikbilagiarts7213 4 года назад +18

    I am not the first....😗
    I am not the last....😄
    But as the notification came...😯
    I click it so fast..!!!!.😲
    That my phone got blast..!!!.😨
    🌻🌻🌻
    😂😂😂

  • @rupamsud718
    @rupamsud718 4 года назад +1

    welcome back YK

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

    Thank you so much, these vedios are very helpful 🌸🌸🌸

  • @milnueve89
    @milnueve89 4 года назад +8

    Thanks, man. This is extremely illustrative and helpful! Your illustrations make it clear. You're a true teacher.
    Please, keep doing it!
    PS: I don't know what the heck an octopus was doing there, but I like it.

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

    Thanks a lot this was extremely helpful

  • @ishanpokhrel5972
    @ishanpokhrel5972 4 года назад +2

    make a video in priority queue and heaps love from nepal❤

  • @doniyorrustamov996
    @doniyorrustamov996 4 года назад

    hello bro l really like your explanation 👍it is amazing. l hope you will not stop making video anymore. If you make video about why you couldn't make video during these times it would be very good video. good luck everytime thanks in advance !!

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

    Thank you i like your explanation

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

    thanks! that's so easy to understand!

  • @shashankkr1008
    @shashankkr1008 4 года назад

    Great explanation 👏👏👏

  • @shubhambhardwaj8894
    @shubhambhardwaj8894 4 года назад

    Awesome explanation ❤

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

    Amazing, I just subscribed!

  • @NaveenKumar-uq6zd
    @NaveenKumar-uq6zd 4 года назад

    Thanks for teaching us!!

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

    Thank you. This channel really helps me with my data structures homework and such!

  • @Gooman15YT
    @Gooman15YT 4 года назад +1

    excellent, i learned it all

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

    solution in python
    class Stack:
    def __init__(self):
    self.items = []
    def isEmpty(self):
    return self.items == []
    def push(self, item):
    self.items.append(item)
    def pop(self):
    return self.items.pop()
    def peek(self):
    return self.items[len(self.items)-1]
    def size(self):
    return len(self.items)
    def parChecker(symbolString):
    s = Stack()
    balanced = True
    index = 0
    while index < len(symbolString) and balanced:
    symbol = symbolString[index]
    if symbol in "([{":
    s.push(symbol)
    else:
    if s.isEmpty():
    balanced = False
    else:
    top = s.pop()
    if not matches(top,symbol):
    balanced = False
    index = index + 1
    if balanced and s.isEmpty():
    return True
    else:
    return False
    def matches(open,close):
    opens = "([{"
    closers = ")]}"
    return opens.index(open) == closers.index(close)
    print(parChecker('{({([][])}())}'))
    print(parChecker('[{()]'))

  • @crist2000a
    @crist2000a 13 дней назад

    First time hear that array can be pointed by last element.

  • @vishalpawar096
    @vishalpawar096 4 года назад

    You are great man.... And too cool

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

    wow this helped me understand stack and queues easily Thank you really..... but i was curious how was he presenting like this?? i mean what tools are you using?

  • @veerrathod3747
    @veerrathod3747 4 года назад

    Thanks brother it really helped

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

    During a stack pop operation, is the top value deleted first and the value of "top" decremented after, or is it the other way around?

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

    it feels like a crime watching this for free..

  • @magacaygamaxamuud7253
    @magacaygamaxamuud7253 4 года назад

    Thanks cs dojo

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

    Can i combine queue and linkedlist? like making an algorithm that uses both algorithms' features? is it doable? or these two cannot be combined techicaly?..

  • @haomintian6815
    @haomintian6815 4 года назад +2

    Hi Dojo! thanks for the cool video! Always fun and inspiring! I just started on coding, I wonder if I should focus more on algorithms or actual project?

    • @CSDojo
      @CSDojo  4 года назад +1

      I would say, work on a project first! I think having some inspiration is important.

  • @rupamsud718
    @rupamsud718 4 года назад +1

    Can you make a series on java please. Cheers

  • @Gooman15YT
    @Gooman15YT 4 года назад

    bro what how is it possible to be this early to a coding video

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

    I was wondering, won't it be much convenient if we used linked list instead of an array?

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

    Small Tip: Maybe explain what stacks and queues are useful for before explaining how they work. In that order I want to know how they work and why they are important.

  • @udaykiran6250
    @udaykiran6250 4 года назад +1

    Hello dojo please suggested a book for starting Java programming (beginner(starting))

    • @CSDojo
      @CSDojo  4 года назад +1

      Hmm actually I'm not sure, but I just started a Twitter thread here: twitter.com/ykdojo/status/1316926401354846208
      Hopefully someone will answer it

    • @udaykiran6250
      @udaykiran6250 4 года назад

      Thank you dojo 😍

  • @II_xD_II
    @II_xD_II 4 года назад

    A video on graph
    and their algos
    like bfs dfs dijkstra

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

    what is 0(1)?

  • @subham2593
    @subham2593 4 года назад +1

    Love you bro

  • @godwinprecious2713
    @godwinprecious2713 4 года назад

    wtf!
    How come I wasn't notified by RUclips when you posted this video?!?

  • @davidpalafox6978
    @davidpalafox6978 4 года назад +1

    Is statistics major good for data science if so would I need a masters?
    Good to see CS Dojo posting more!

    • @CSDojo
      @CSDojo  4 года назад +2

      Thank you, yes, and about master's - not sure. I think if I was you, I would do CS because it's easier to get a job with it. CS undergrad degree and whatever master's degree you feel like you need if you think you need it.

    • @davidpalafox6978
      @davidpalafox6978 4 года назад

      @@CSDojo yeah I’ve been struggling with my CS major, but I guess I just gotta put more effort then what I have been doing I’m in my 3rd year. Thanks!

    • @procode6881
      @procode6881 4 года назад

      Which software you use to make these illustrations

  • @raymondjude47
    @raymondjude47 4 года назад

    You videos are awesome bro, what software are you using to record your screen?

    • @CSDojo
      @CSDojo  4 года назад +1

      Thank you. I talk about all of it here: www.csdojo.io/faq

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

    Thank you Sir

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

    Wouldn't it be better to use a linked list to implement a stack?

  • @dianneroces883
    @dianneroces883 4 года назад

    Hi CS Dojo, I was wondering if you could help me with Google not responding issue. It causing me too much trouble. Thanks in advance.

  • @weltmeister
    @weltmeister 4 года назад

    I would've needed this a couple months ago

  • @nono-eh9lz
    @nono-eh9lz 4 года назад

    Please start live classes for beginners on zoom.

  • @MinatoNamikaze18034
    @MinatoNamikaze18034 4 года назад +1

    Hey dojo i am a indian school student class 12 I want to be a data scientist so which language I should learn first c++ or python... Please answer my question.

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

      I would go with Python :)

    • @arigatou9199
      @arigatou9199 4 года назад

      C++ is a way harder, so for begging python is one of the best , also python is really popular for data science rn and have a bunch of libraries, etc.

    • @MinatoNamikaze18034
      @MinatoNamikaze18034 4 года назад

      @@CSDojo thanks man

  • @Otthavada
    @Otthavada 4 года назад

    Bro I don't know nothing but I am in the 3 year of my engineering.what should I learn.any suggestions bro.please do reply

  • @minecraftepicscarboy6885
    @minecraftepicscarboy6885 4 года назад

    Hello yk can you make a video on how to make a working clock using python programming

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

    THANK YOU

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

    I just went thru data structures and didn't learn anything 😞. G.ad I saw this video.

  • @vishalpawar096
    @vishalpawar096 4 года назад

    Can you make a video on how to learn c++ and java

  • @OforiwaaAmanfo-Sam
    @OforiwaaAmanfo-Sam 4 года назад

    You’re amazing!

    • @CSDojo
      @CSDojo  4 года назад

      Thank you!