Stacks and Queues

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 444

  • @derekbanas
    @derekbanas  11 років тому +1

    I have constantly tried to find ways to make my videos better. Coupling them with learning apps felt like a great way to do that. I make enough money. I don't need anymore. I'm just happy that people are finding the videos useful

  • @kiullsmith
    @kiullsmith 11 років тому +17

    These tutorials are a savior to my life! Being a Comp Sci major with bad teachers and TAs these teach me more then my classes!

    • @derekbanas
      @derekbanas  11 років тому

      Thank you :) I'm very happy I can help to explain what your teachers missed

    • @musawenkosintombela3797
      @musawenkosintombela3797 4 роки тому +1

      Jeramy smith can we chat private?

  • @BuckstarrZ
    @BuckstarrZ 10 років тому +43

    You are just THE BEST source for programming stuff on this planet, forget about the lectures given by our profs and tutors - you are the real deal.
    It's amazing how you just don't miss a thing, everything anyone could think of simply exists in your video collection. I wouldn't have it through my exam without this!

    • @derekbanas
      @derekbanas  10 років тому +8

      Thank you very much for the kind message :) People like you are the reason why I continue making videos.

    • @scoobynicker
      @scoobynicker 10 років тому +6

      I second what he said.
      I've been using you through the whole semester, almost every single day.

    • @derekbanas
      @derekbanas  10 років тому +3

      Nick Steiner Thank you :) That is very nice to hear that I helped.

  • @abdallaelmedani2316
    @abdallaelmedani2316 9 років тому +20

    Thank you for the marvelous work, Derek. Your style, speed and code accuracy is just amazing.

    • @derekbanas
      @derekbanas  9 років тому

      +abdalla elmedani Thank you for the compliment :) You're very welcome

    • @user-tk7sc4gz2v
      @user-tk7sc4gz2v 2 роки тому

      Agree with this for other videos but not this, major issue in code for queue size handling among other things. Size x, insert x elements, remove y elements and try inserting. (Ideally space should be there because we removed y elements but the code would throw exception)

  • @luckymesoup
    @luckymesoup 10 років тому

    I finished school two years ago and sadly I haven't been in a programming role at my current job. I honestly feel like the saying "if you don't use it, you lose it" is true.
    Your tutorials have been a huge help in getting me back on my feet. Thank you!!

    • @derekbanas
      @derekbanas  10 років тому

      Thank you :) Keep at it. The world needs plenty of programmers. You'll find the job you're looking for.

  • @dmkerr
    @dmkerr 6 років тому

    Just want to echo the many users over now several years: thank you so much for sharing your knowledge. You really do have a unique talent for clear instruction and example. I'm working my way through a few Java-based courses right now and each new chapter seems difficult or confusing until I watch and follow along with your video covering the topic.

    • @derekbanas
      @derekbanas  6 років тому

      Thank you for taking the time to write such a nice message :) I greatly appreciate it !!!

  • @MAGonzzManifesto
    @MAGonzzManifesto 10 років тому +1

    I'm studying for my Data Structures midterm and I'm SO glad I found your channel! You have tons of videos on subjects that I'm super interested in and you are very good at explaining things clearly and quickly. Also, your videos are great and easy to follow. Thanks!

    • @derekbanas
      @derekbanas  10 років тому

      MAGonzzManifesto Thank you for all the nice compliments :) Many more videos are coming.

  • @vericlese
    @vericlese 8 років тому

    I'm so glad you exist in the world. My instructors give me tasks but you teach me how to learn java. Thank you for doing what you do!

    • @derekbanas
      @derekbanas  8 років тому

      Thank you for the nice compliment :) I'm very happy that I helped

  • @SohCahToa30
    @SohCahToa30 10 років тому +42

    Queues starts at 9:06

  • @iRtehKatz
    @iRtehKatz 11 років тому

    I use your videos for studying. Very well made. So much easier than re-reading slides and chapters from books. I appreciate all the time you put into making these.

  • @alohiyaalohiya7745
    @alohiyaalohiya7745 8 років тому

    You are better than all of my C.S professors at college. Thanks man for these tutorials. You made this seem so much easier.

    • @derekbanas
      @derekbanas  8 років тому

      +Ankur Lohiya Thank you for the nice compliment :) You're very welcome

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :) many more are coming as quickly as possible

  • @MrJonathanRB
    @MrJonathanRB 10 років тому

    Derek I really appreciated all the time, that you have been taking from your personal life to provide us such as great tutorials, I have not a lot of money to pay for teachers and all that stuff and you had been the greatest source of information regarding Java programing. God bless sir

    • @derekbanas
      @derekbanas  10 років тому

      Thank you very much for the compliments :) There is no money required. I'm happy I could help. May God bless you as well.

  • @derekbanas
    @derekbanas  11 років тому +1

    Thank you :) I'll show exactly how to do that when I cover how to make stacks and queues with Linked Lists. You made a great point, but you are getting a bit ahead of me.

  • @derekbanas
    @derekbanas  11 років тому +2

    He subido el video antes de acostarse. Estoy haciendo videos tan pronto como sea posible. Yo no esperaría que una todos los días a las 11 :)

  • @derekbanas
    @derekbanas  11 років тому +1

    Thank you for taking the time to write such a nice message :) You're very welcome and may God bless you and your loved ones as well.

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :) I do my best to present the information in new ways. I'm glad they are helping.

  • @derekbanas
    @derekbanas  11 років тому +1

    Thank you :) Some day maybe I'll cover different topics again. I love to teach different topics. The programming stuff just come easy to me though because I have been doing this stuff all my life.

  • @derekbanas
    @derekbanas  11 років тому +1

    Thank you :) As the tutorial continues I use them for sorting and other things. I hope they help

  • @timo113
    @timo113 10 років тому

    Thank you for putting up these tutorials. You deserve to be commended for this.

    • @derekbanas
      @derekbanas  10 років тому

      You're very welcome :) The pleasure is all mine. I have met many wonderful people all over the world from doing this.

  • @hotmandead1
    @hotmandead1 9 років тому

    Love your Coding Skills Sir,
    Especially the Easy Variables you use Solve half the Problem and the display methods just LOVE !

    • @derekbanas
      @derekbanas  9 років тому

      hotmandead1 Thank you :) I'm glad you enjoy them

  • @derekbanas
    @derekbanas  11 років тому

    You're very welcome :) I'm glad you enjoyed the video

  • @Juznik1389
    @Juznik1389 9 років тому

    One night to finish my lab. YOU made it possible! Thank you so much! :)

    • @derekbanas
      @derekbanas  9 років тому +1

      Kalle Great I'm glad I could help :)

  • @vborole
    @vborole 11 років тому

    Derek, I must tell you this, you are doing a real good work with your videos, your way of explaining such complex concepts are simply the best. I like all your videos, thank you so much. Take care and god bless!

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

    Stacks like a stack of drying dishes; You take the one on top off first. Queues are like a queue for a bus. First come first served.

    • @derekbanas
      @derekbanas  5 років тому

      Thanks for helping others :)

    • @tyty21315
      @tyty21315 5 років тому

      Derek Banas and thank you for helping me through university!

  • @marvinhawkins2000
    @marvinhawkins2000 10 років тому +1

    This is just what i needed. It's way more direct than my dry programming book. Subscribing!

  • @JENNYLENE96
    @JENNYLENE96 10 років тому

    Your presentations are very good and well put together.... You deserve an award for this...

    • @derekbanas
      @derekbanas  10 років тому

      Thank you :) Appreciation is more then enough for me.

  • @yayalunet
    @yayalunet 10 років тому

    Thank you so much for all of these Java tutorials! You are honestly a lifesaver! :)
    In the past two hours I have learnt soooooo much, just from watching your videos!

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :) I have been playing around with how I could provide homework and tools to reinforce the information. I'm working on a framework that I plan to use to make tablet / phone apps that will provide those tools. Don't worry they will be free. I'm planning to start making them over the coming months. It should be fun

  • @RatherBAnon
    @RatherBAnon 10 років тому

    Very helpful, Derek.
    Learned a lot, and I deeply appreciate your contribution to the learning.

    • @derekbanas
      @derekbanas  10 років тому

      Thank you very much :) I'm glad you found it useful.

  • @idanshoukroun4808
    @idanshoukroun4808 8 років тому +1

    Your push method will display two messages in case that the stack is full. One that the stack is full and one that the input was added. You had to put the last line inside the condition.

  • @LoneStarVII
    @LoneStarVII 9 років тому +5

    I think for this the 'sysout("PUSH " + input + " added to stack")'
    should be inside the if statement. If not what would happen hypothetically is that if the stack is full it's still going to print that the input was pushed, even though it's full.

    • @derekbanas
      @derekbanas  9 років тому +2

      Lone Star VII Good point :)

  • @gopalb6975
    @gopalb6975 10 років тому

    Thank you so much Sir for doing all these your are providing best video tutorials in the planet

    • @derekbanas
      @derekbanas  10 років тому

      Thank you very much for the nice compliment :)

  • @derekbanas
    @derekbanas  11 років тому

    Yes I will cover most everything. The only issue I'm having is that some topics require knowledge of discrete mathematics. I'll do my best to make all of that understandable without making a tutorial on discrete math

  • @CSEconceptswithParinita
    @CSEconceptswithParinita 4 роки тому +1

    Thank you so much ! You're an inspiration for new tutors like me🙏

  • @vivilee7290
    @vivilee7290 7 років тому

    Your programming is amazingly proficient! I like all the algorithms videos.

  • @derekbanas
    @derekbanas  11 років тому

    I wish you the best on your travels. The only traveling I've ever done is in books pretty much :)

  • @NickTunac
    @NickTunac 11 років тому

    Great Idea. Make exercises after the tutorial. Just like in schools :P after the discussion there's an exercises about the lecture. Great tuts Derek.

  • @rahmanalifarishta4588
    @rahmanalifarishta4588 10 років тому

    I just can't thank you enough for such knowledge packed videos

    • @derekbanas
      @derekbanas  10 років тому

      You're appreciation is all I require. I'm very happy that you enjoy the videos :)

  • @aks690
    @aks690 11 років тому

    You are awesome Derek. These videos are a boon for interview preparations. 6 hour revision for the basic data structures!!..Thumbs UP..:-)

  • @shubhamkahal2828
    @shubhamkahal2828 10 років тому

    Thank you for taking the time to put up these tutorials, they are awesome and very appreciated!!

    • @derekbanas
      @derekbanas  10 років тому

      You're very welcome :) I'm glad you like them.

  • @UziasLara
    @UziasLara 7 років тому

    This is sure to help in my Data Structures & Algorithms class. Thanks.

  • @mickeymalotte1076
    @mickeymalotte1076 8 років тому +2

    Holy crap, I kind of understand java now! Thank you sir.

    • @derekbanas
      @derekbanas  8 років тому +1

      I'm happy I could help :)

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :) Everyone is very nice to me and that is all I need.

  • @derekbanas
    @derekbanas  11 років тому

    Yes stacks are very much part of how computers and compilers work on a basic level

  • @SuperMCToaster
    @SuperMCToaster 5 років тому

    Hey man thanks for the video. It helped me a lot to get into stacks and queues. So it came, that I noticed a MAJOR mistake in your stack pop method. In line 45 you set the TopOfTheStack to -1 and also increment one down in line 47. In this case, it does not matter because you get your value printed out before but if you actually want to work with the method for advanced applications you always get the wrong output of always -1.

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

      What would be a fix to this error then? I’m genuinely curious.

  • @derekbanas
    @derekbanas  11 років тому

    What are you looking for? Like exercises in text books? The only problem is that I don't have time to solve all of them, but I could give exercises that you should be able to solve if that works

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :) I have to cover other common interview questions that I don't cover here and in the design patterns tutorial

  • @NickSarahnCoco
    @NickSarahnCoco 10 років тому

    Thank you so much for your great videos. You explain everything in such a clear manner. I look forward to watching all your videos.

    • @derekbanas
      @derekbanas  10 років тому

      Thank you very much :) I appreciate the nice message.

  • @rujiahao4284
    @rujiahao4284 10 років тому

    man, u did a really excellent job to illustrate every details! super helpful, I certainly cant understand if i only saw each video once, ;) thank u so much!

    • @derekbanas
      @derekbanas  10 років тому

      rujia hao Thank you for the nice compliment :) You're very welcome

  • @MexterO123
    @MexterO123 11 років тому

    You saved this CS students butt, thanks dude. I'm never procrastinating on my CS projects again. Let me tell you that. : D

  • @zeenpc5645
    @zeenpc5645 7 років тому

    You are huge inspiration to me. Thank you for everything.
    Your programming skills, editing skills and a powerfull voice I can just dream about, make this videos perfect :)

    • @derekbanas
      @derekbanas  7 років тому

      Thank you for the nice compliment :)

  • @charlesperry6408
    @charlesperry6408 7 років тому +1

    You are great. I'm in my second semester of grad school, and after taking one semester of part 1 and 2 of core Java, and watching a few of your tutorials, you have given me confidence that I'll be OK in my Algorithms class this semester! Thank you. Please keep this going. Any advice you might have? Again, thanks! Also do you cover Discrete math?

    • @derekbanas
      @derekbanas  7 років тому +1

      Thank you very much :) I'm happy the videos are helping. Sorry, but I haven't covered discrete mathematics yet

    • @charlesperry6408
      @charlesperry6408 7 років тому

      Derek Banas Got it! Another question, do you have any videos where you actually compare algorithms using graphs and the "Big Oh" notation? Or Algo analysis in general? Again, the code is great stuff!!!!

    • @derekbanas
      @derekbanas  7 років тому

      Yes I cover Big O here ua-cam.com/video/V6mKVRU1evU/v-deo.html

  • @brandedmagnus909
    @brandedmagnus909 7 років тому

    Literally an entire semester in Computer Science summarized perfectly in 16 minutes.

    • @derekbanas
      @derekbanas  7 років тому

      I do my best to not waste time :)

  • @Nikhil-fm4ii
    @Nikhil-fm4ii 7 років тому

    one advice although a small one if you are taking input from the terminal using scanner use scanner object on nextLine() instead of next() method call as next will only pick the first word however we would want the entire line to be used and hence should use nextLine().

  • @conairspy77
    @conairspy77 10 років тому +5

    i keep thinking what happens when the front and rear keep moving down the array and eventually go out of bounds? If the Front starts at index 4 of a array that has the size 5, then when you add an element to it wouldn't it go out of bounds

  • @mikebrow6259
    @mikebrow6259 11 років тому

    You are very good at this! You deserve a hug and HUGE pile of money :)

  • @myeon859
    @myeon859 6 років тому +7

    Stack starts at 16:16
    java.lang.NullPointerException

  • @derekbanas
    @derekbanas  11 років тому

    I just used an array because everyone understands arrays. I'll provide more examples as the tutorial continues

  • @manohars211
    @manohars211 9 років тому

    Thanks for all the tutorials! Its crisp, clear and excellent. Btw, what is the first sentence you always say in your videos? I couldn't decode that completely :)

    • @derekbanas
      @derekbanas  9 років тому +2

      +Manohar Sripada You're very welcome :) I say "Well Hello Internet"

  • @derekbanas
    @derekbanas  11 років тому

    Yes I have linked lists tutorials in the algorithm tutorial on my UA-cam channel

  • @deanbartolo3244
    @deanbartolo3244 8 років тому

    This is extremely helpful, job well done !

    • @derekbanas
      @derekbanas  8 років тому

      +Dean Bartolo Thank you very much :)

  • @MexterO123
    @MexterO123 11 років тому

    Always a pleasure listening to your lectures. Continue the good work bro. : )

  • @derekbanas
    @derekbanas  11 років тому

    I'm very happy that I could help :)

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :) I try to do my best.

  • @TheHTMLCode
    @TheHTMLCode 11 років тому

    is there anything you don't do teach!
    great revision guide, thanks Derek.

  • @rafiaqutab8174
    @rafiaqutab8174 9 років тому +2

    Perhaps the pop() method should be returning the oldValue prior to setting it to "-1"; hence:
    public String pop(){
    if (topOfStack >= 0) {
    // display and print e.t.c
    String value = stackArray[topOfStack];
    stackArray[topOfStack--] = "-1";
    return value;
    }
    //else print and report stack is empty e.t.c
    }
    ** I didn't check all the comments below to see whether anyone mentioned this **

    • @BlackGhost13Kh
      @BlackGhost13Kh 5 років тому

      I also thought the same thing.
      public String pop() {
      String rep="";
      if(topOfStack>=0) {
      display();
      System.out.print("
      POP: The value at the top of the Stack "+stackArray[topOfStack]+" was removed from the Stack");
      rep=stackArray[topOfStack];
      stackArray[topOfStack]="-1";
      topOfStack--;
      }
      else {
      System.out.print("POP: the Stack is empty apparently. Unable to pop any Value.");
      }



      return rep;
      }

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

    Thank you so much you saved my finals

    • @derekbanas
      @derekbanas  5 років тому

      I'm happy I could help :)

  • @123japanuser
    @123japanuser 11 років тому

    Hola entrenador,
    Gracias por este video muy conceptual.
    Es una base.
    También se alegrarán de saber que tengo en el cuadro de medallas.
    Silver para mí!!
    Ahora sé que el vídeo en tiempo es 11 pm EST :)

  • @nadiakhadem1845
    @nadiakhadem1845 8 років тому

    Write a complete Java program that provides a method named isPalindrome, which takes a
    Queue of integers as a parameter and returns true if the numbers in the Queue represent a
    palindrome (and false otherwise). The empty Queue should be considered a palindrome.
    You may use one Stack as auxiliary storage.

  • @derekbanas
    @derekbanas  11 років тому +1

    Thank you :) Basically I have everything in playlists. This is the order I would teach : Java Video Tutorial, Design patterns, UML, Object Oriented Design, Code Refactoring, Algorithms. I have everything in order on this page : newthinktank. com/2011/10/every-article/#java

  • @trappedcat3615
    @trappedcat3615 7 років тому

    Sat in 1+ hour lecture on stacks at college. Came here to actually learn it and in 15 minutes.

    • @derekbanas
      @derekbanas  7 років тому

      I'm happy I could help :)

  • @kaeiaoemaoe9740
    @kaeiaoemaoe9740 9 років тому

    First off, let me say, great videos!! I'm refreshing my knowledge in the subjects because I essentially flushed em after my courses to make room for new info lol. I just had a small question... why not move all of the elements up after removing an item in the queue, to maximize space for new inserts?

  • @mmedie
    @mmedie 11 років тому

    Hi Derek thanks a lot of your videos. The insert method you use in the queue class is it the same as enqueue() which adds new items to the end of the queue. thanks in advance

  • @Kizer5Red
    @Kizer5Red 9 років тому

    makes sense
    I kind of like Stacks more then Queues, but I'm still new to them both.

  • @udarachinthaka1
    @udarachinthaka1 7 років тому +1

    Your are awesome teacher, Thank You.

  • @derekbanas
    @derekbanas  11 років тому

    You're very welcome :)

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

    WELLHELLODEREK! Thank you for the video from 2019!

    • @derekbanas
      @derekbanas  5 років тому

      Well Hello :) I'm happy to be of help

  • @ashmeetkaur4067
    @ashmeetkaur4067 6 років тому

    I think in insertPriority, ur for loop must span from rear to front instead, as numberOfItems may get decreased after some elements are deleted.

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

    This implementation is through arrays, i needed the linked list implementation cuz thats the one everyone asks

  • @alexanderfedorenko3398
    @alexanderfedorenko3398 8 років тому

    Great explanation! Thank you!

  • @yasserhisham8778
    @yasserhisham8778 11 років тому

    Thanks. Great tutorial. But shouldn't you wrap the rear and the front to the beginning of the array if they are equal to the arraySize? I mean just increasing them will cause a null pointer exception at some point.

  • @agungsurya7070
    @agungsurya7070 10 років тому

    thank you sir, i really glad to watch your tutorials :)

  • @qwe123727
    @qwe123727 9 років тому +1

    Derek,
    'priorityInsert()' methods has a serious bug. Quick check, remove an item and call this method. Reason is, for-loop condition in this method is wrong.

    • @mindtrackeryun24
      @mindtrackeryun24 9 років тому

      +Ethashamuddin Mohammed yeah, need to check if queue is full. otherwise queueArray[i + 1] doesnt exist

  • @duhbruno
    @duhbruno 7 років тому

    Really nice content dude... keep doing the great job!
    Btw, nice reference to the Stephen King's master piece on the code... It was "shining" !

    • @derekbanas
      @derekbanas  7 років тому +1

      Thank you very much :) You got it

  • @CelticSongbird9642
    @CelticSongbird9642 6 років тому

    The push and pop statements are good for debugging purposes

  • @Cezkarma
    @Cezkarma 8 років тому +37

    dude you are awesome

    • @derekbanas
      @derekbanas  8 років тому +6

      Thank you for the compliment :)

    • @vericlese
      @vericlese 8 років тому

      J-Walker Official Truth!

  • @derekbanas
    @derekbanas  11 років тому

    Thank you :)

  • @AlexanderMcNulty92
    @AlexanderMcNulty92 6 років тому

    Good tutorial as always, although I would have been more interested to see this done in a linkedlist fashion.

  • @Cryogenics12
    @Cryogenics12 10 років тому

    Actor John Goodman was the instructor of my first foray into Stacks and Queues. How cool is that????

    • @derekbanas
      @derekbanas  10 років тому

      Cryogenics12 That's funny :D

  • @tommylee1029
    @tommylee1029 10 років тому

    Hey you thanks for the videos they help alot!

  • @silambarasannv9070
    @silambarasannv9070 8 років тому

    thank you sir. great tutorial

    • @derekbanas
      @derekbanas  8 років тому

      I'm very happy that I could help :)

  • @mmmmSmegma
    @mmmmSmegma 10 років тому

    If you leave out the condition for the Queue to be full, Would you then have in the remove method : rear++; then rear = rear % maxNumOfItems. Similarly for insert would you then have front++; then front = front % maxNumOfItems? That way you can keep adding and removing stuff?

  • @josephkremer1797
    @josephkremer1797 10 років тому

    Really great videos, I've learned so much so quickly!!! :)

    • @derekbanas
      @derekbanas  10 років тому

      Joseph Kremer Thank you very much :)

  • @vericlese
    @vericlese 8 років тому +1

    Forgive my ignorance as I am very new but in your pop method, the stack is displayed prior to the -1 assignment. This causes the display to show the value removed. I moved the under the "-1" assignment, just above the return and now it displays the stack without the popped value. Am I correct in doing this or is there something I missed. Again, you rule!
    New version:
    public String pop(){
    if(topOfStack >= 0){
    System.out.println("POP " + stackArray[topOfStack] + " Was Removed From the Stack
    ");
    // Just like in memory an item isn't deleted, but instead is just not available
    stackArray[topOfStack] = "-1"; // Assigns -1 so the value won't appear
    displayTheStack();
    return stackArray[topOfStack--];
    }

  • @oscarchivas3123
    @oscarchivas3123 9 років тому

    PrioriyQueues follow a min-heap data structure so they don't necessarily end up in ascending or descending order

  • @Nikhil-fm4ii
    @Nikhil-fm4ii 7 років тому +1

    i have one doubt derek bans regarding the insertion operation that inside the insertion operation should we keep the if condition like this if(numberOfItems < queuesize) then we should go further i guess the condition if(numberOfItems +1

  • @sbasalan
    @sbasalan 11 років тому

    Hi Derek, greetings from İstanbul city. My training will be finished on next Tuesday then I'll fly to Jakarta and start to work there. Hope you're doing alright

  • @edersantos1735
    @edersantos1735 7 років тому

    Dude !! you rock!!!!! best video period

  • @showieeliezer2951
    @showieeliezer2951 8 років тому +3

    Why when I type the displaySTack, there is an error. Should I do a other method to display the output?
    how did you do that?

    • @vidhimehta6252
      @vidhimehta6252 6 років тому

      It think you need to make your own method for printing out the stack