Stack Data Structure | JavaScript

  Рет қаралды 95,745

Traversy Media

Traversy Media

4 жыл бұрын

In this video, we will look at the stack data structure using JavaScript. This is part of an ongoing data structure playlist
Code:
gist.github.com/bradtraversy/...
💖 Become a Patron: Show support & get perks!
/ traversymedia
Website & Udemy Course Links:
www.traversymedia.com
Follow Traversy Media:
/ traversymedia
/ traversymedia
/ traversymedia

Пікірлер: 318
@TraversyMedia
@TraversyMedia 4 жыл бұрын
This will be an ongoing series. I know it is a bit different than the projects/crash courses I usually do, but it is really good practice. I will be reviving the JS Cardio series as well. Maybe do some Codewars :)
@tomershechner7449
@tomershechner7449 4 жыл бұрын
I'll just lay a couple of DSes ideas for your next videos: - Hash tables (associative arrays, aka maps) - Dynamic array (aka vectors) - Binary trees - Queues - Heaps - Sets I implemented them all in C once, it'll be cool to see you using a language other than JS, something which is closer to the metal, like C, Rust or even Go. Peace Brad, I appreciate the effort you put into your videos!
@swanstudios2018
@swanstudios2018 4 жыл бұрын
Traversy Media love some code wars that would be a nice mix of content! Thanks so much brad!
@khotambakhromov
@khotambakhromov 4 жыл бұрын
how the method pop removes element? tbh, I couldn't find out how it works and deletes item
@Buyilehuorg
@Buyilehuorg 4 жыл бұрын
shouldn't we add this.items.pop() inside pop method? otherwise it's kinda still there, no? Could you please make examples how to use those with real world implications? I mean examples explaining why we want to use it instead of arrays for instance etc. Thank you very much for your videos and Udemy courses
@princesiful
@princesiful 4 жыл бұрын
great
@Ath9493
@Ath9493 4 жыл бұрын
Really happy that brad started data structure series
@ryan.aquino
@ryan.aquino 4 жыл бұрын
Please continue this series: data structures and algs. Include stack, queues , heap , graph , trees. You explain things simpler than others ! Thanks. Edit: Include atleast 1 coding problem And 1 realworld example.
@uchechukwuprincenwulu2026
@uchechukwuprincenwulu2026 4 жыл бұрын
im in support with his comment
@michaelolukaka
@michaelolukaka 4 жыл бұрын
waiting for the next data structure...good stuff
@EngerJimenez
@EngerJimenez 3 жыл бұрын
I support this.
@toberixng
@toberixng 3 жыл бұрын
that is the honest truth
@EntwistleOx
@EntwistleOx 3 жыл бұрын
support!
@abualmahadi8084
@abualmahadi8084 4 жыл бұрын
Now that you've started the series I'm already feeling confident about finally learning about the data structure and algorithm......sooo much love and respect
@safara_umarov
@safara_umarov 4 жыл бұрын
Really! You are great teacher in the KZbin I'm from Tajikistan and I started learning programming with your videos and now I know many many things. Thank you my brother❤)). With our language not one video about programming and I don't know English good! Your videos help me very. Thank you again
@shutdownyes
@shutdownyes 3 жыл бұрын
Thanks, Brad! Really glad to see your videos about Data Structure! Strongly waiting for the rest videos in this area!
@ravijaiswal_7
@ravijaiswal_7 4 жыл бұрын
Looking forward to the complete series of data structures and algorithms, the way you take the flow of your explanation makes things look very easy.
@JamieMcGibbon
@JamieMcGibbon 3 жыл бұрын
Great video! Thanks for taking the time to put it together! Looking forward to the others in the series!
@mauricioreyes8912
@mauricioreyes8912 4 жыл бұрын
Dude, Im coursing data structures in the collegue now, you have this skill to explain things really good. Keep going. Really great channel.
@GTsurwa
@GTsurwa 4 жыл бұрын
So glad you are doing stuff like this Brad. Still yet to find a web dev job, so videos where I can keep learning really help keep motivated. Thank you 1000 times.
@mannyc1065
@mannyc1065 4 жыл бұрын
I'm taking a data Structures course at school next semester so this is perfect timing!! Thank you!
@jmmacatangay_grizzlybear
@jmmacatangay_grizzlybear 4 жыл бұрын
It's really amazing how people come into your channel. It's about 21 minutes ago in my time and a hundred people seen it already. It's really amazing that a lot of people appreciate you. Been telling my friends about your channel. Really hoping you'll get a billion subscriber someday.
@thedanphillips
@thedanphillips 3 жыл бұрын
Honestly the fact that you still provide free stuff on YT and not just Udemy is the best. I'm already familiar with Stacks but it's nice to see your content quality is great even when it's free! Keep it up, more people like you in the world is what we need.
@soumadip_skyy_banerjee
@soumadip_skyy_banerjee 4 жыл бұрын
Yaaayyy! Plz! Connect these data structure videos in a series! (small tip: Add some theory too). U're again, my hero in the Tech world! Thankeeww so much! I needed this! 💚
@truphenalwanga9829
@truphenalwanga9829 3 жыл бұрын
Can' t wait to see more on this series. Great start.
@xXDameanXx
@xXDameanXx 4 жыл бұрын
Many thanks for creating this content and sharing this knowledge, algorithms, and design patterns are needed out there but no one is teaching them
@xaviguasch
@xaviguasch 3 жыл бұрын
This is great! I always wanted Brad to tackle data structures and algorithms in JS, please continue.
@onedimensionalchess4373
@onedimensionalchess4373 3 жыл бұрын
Beautiful!! I’m about to get into this topic, so it’s nice to see my favorite teacher explaining it.
@rezamarefat6894
@rezamarefat6894 3 жыл бұрын
Please keep making these kinda content brad. Your channel is incredible
@mudusugal
@mudusugal 4 жыл бұрын
your explanations are very clear and easy to understand. Thank you!
@benomayio3666
@benomayio3666 Жыл бұрын
Thanks man! I always enjoy your tutorials
@Melanittanigra
@Melanittanigra 4 жыл бұрын
Please continue with this series, it is very hard to find information on algorithms and data structures in regards to JavaScript
@akiratoriyama1320
@akiratoriyama1320 3 жыл бұрын
This is great tutorial sir!! You are helping with our computing thinking!! Thank you!! Hope you made a whole series on data structures because you explain things on simple way!!
@annyudo
@annyudo 2 жыл бұрын
Thank you so much, I really enjoy all your videos, the concepts you use and your explanations are very concise. You are a great teacher. Pls keep up the good work.
@mohsin6312
@mohsin6312 4 жыл бұрын
Thank you Brad. Looking forward to this new series.
@Unbridledhopebr
@Unbridledhopebr 3 жыл бұрын
Hey, I AM A BIG fan of your work. I can easily understand what you teach. thank you very very much for selling your courses at such an affordable price and outstanding quality. Hug from Brazil.
@paschalynukwuani6980
@paschalynukwuani6980 Жыл бұрын
Thank you so much for this video. I really understood everything. I must say you are a good teacher. Love your content 💓
@tom.watkins
@tom.watkins 4 жыл бұрын
Great video, only thing that I was surprised to see was the pop method not actually reducing the size of the internal array. Looking forward to the other videos in the playlist!
@_rachid
@_rachid 3 жыл бұрын
Thank you Mr Brad for this. By the way your course Javascript from the beginning on udemy is gold 👌 Greetings from Morocco 🇲🇦
@princesiful
@princesiful 4 жыл бұрын
Awesome!! Really happy that you started data structure series
@TheNerdyDev
@TheNerdyDev 4 жыл бұрын
Something different. That's great, Brad. What a coincidence, I too was working on a data structure tutorial series but with Java language.
@AneesKhan-uz4mz
@AneesKhan-uz4mz 3 жыл бұрын
I always feared data structures and algorithms but Brad you just explained really well now I'm loving data structures and algorithms ❤️❤️
@albertdugba
@albertdugba 4 жыл бұрын
awesome Brad. Having really been looking forward to this. Many thanks big bro
@ThiagoVieira91
@ThiagoVieira91 4 жыл бұрын
Just in time for a productive lunch break! 🙌🏼
@BBI-Brandboost
@BBI-Brandboost 3 жыл бұрын
This is great content. We look forward to the next one in the series.
@cameronthompson1275
@cameronthompson1275 4 жыл бұрын
Awesome! Great start to data structures! Keep up the great work!
@andrei8299
@andrei8299 3 жыл бұрын
Thanks for the video. Just today got to this topic while learning. It was interesting to know how the mothods structured
@eriktenecela7170
@eriktenecela7170 3 жыл бұрын
Bro thanks Traversy man I been telling people these DS/Algorithms are the most important thing to know before anything it will improve your programming mindset dramatically thanks again this channel truly is the best
@BleedingFryTheHeart
@BleedingFryTheHeart 4 жыл бұрын
This is awesome , thank you Brad
@iamjameswong
@iamjameswong 4 жыл бұрын
Hey, nice vid. If I understand it correctly the `.pop` method merely reduces the reference count instead of actually removing the item from the list/stack. Is that right?
@srdjagunjic
@srdjagunjic 4 жыл бұрын
Same...
@jeromesnail
@jeromesnail 4 жыл бұрын
The way the stack works, it is exactly like the item was removed from the stack, even if it is still in the items array. Because we're not supposed to access items from outside of the class.
@greenie62
@greenie62 3 жыл бұрын
ya i was thinking that too and playing around to try to 'break it'...i realized and am curious for someone to confirm, but in this instance pop feels like its.a rewrite method rather then a remove...by that i mean, it gives us the value but rather then remove it, it just backs the counter up one so the next item we push(), it will then overwrite it as its being given the same index value. so, if you pop() and then look at the array right after, the item is still in there, but soon as you push, then its becomes 'gone' and your stack continues on with its indexed integrity. least thats my guess!
@augustodias8986
@augustodias8986 3 жыл бұрын
I just added this.items[this.count] = undefined after decrementing the count
@frankkevintankui7221
@frankkevintankui7221 3 жыл бұрын
Same. 😅 It's a great mistake. We also have to manage the memory in data structure
@sushantkunkekar2155
@sushantkunkekar2155 3 жыл бұрын
One of the best and simple video on stack... Please Brad do videos on other data structures too. Likr hashtable , tree, dynamic programming
@jeanssmith5864
@jeanssmith5864 4 жыл бұрын
me too Really happy that brad started data structure series I will be right here waiting for Brad
@incognitosco
@incognitosco 3 жыл бұрын
This is great Brad especially for interviews ✅
@woozy_deer
@woozy_deer 4 жыл бұрын
Thanks! I love these data structures videos
@novailoveyou
@novailoveyou 3 жыл бұрын
I would love to see testing! Thanks for your videos Brad!
@barathraj9803
@barathraj9803 3 жыл бұрын
Wow thank you so much... I was not confident about DS before but now i am sure that i will understand everything.. Thanks, please upload all the vedios exlpaining all the Dta structures.!!
@MadhusudanBhosale
@MadhusudanBhosale 4 жыл бұрын
The way you handle errors correction, I just love it. #traversymedia #bradtraversy
@F11550i
@F11550i 3 жыл бұрын
Great video like always Brad! In 4:24 instead of those two lines 10 and 11 you could write : return this.count++
@Martin-xx2kw
@Martin-xx2kw 3 жыл бұрын
Bravo Brad! Thanks for the great vid!
@romanahmed5655
@romanahmed5655 3 жыл бұрын
Wow..... Nice series .Thank you brad.
@antio1753
@antio1753 4 жыл бұрын
FINALLYYYYYY DATA STRUCTURES SERIESSSS FROM BRAD THANK GOD
@shachaha
@shachaha 3 жыл бұрын
awesome as usual! I would totally love it to see more of that!! :D
@santosokwadi
@santosokwadi 3 жыл бұрын
Every Video this guys posts, I just click "Like" even before I watch. You have great content Man.
@cristlui4
@cristlui4 4 жыл бұрын
Are you a mind reader? This is truly fantastic. Thank you so much Brad!
@nirtzezana627
@nirtzezana627 3 жыл бұрын
Keep it up with the Data structures, great!
@roothacks6864
@roothacks6864 4 жыл бұрын
I am very happy sir please make a whole series of it❤❤❤
@sujeetagrahari2292
@sujeetagrahari2292 3 жыл бұрын
I am so glad that you doing this. I have been following this channel very long. I don't come here often now. To be honest best channel for beginners to learn new techs. But code quality and best practices lack in this channel, and I don't think this should be a concern when you are introduced something new at first. But if you get a idea of things in the beginning, it will be lot more beneficial for newcomers..
@alisiraj2100
@alisiraj2100 4 жыл бұрын
Thanx brad, Ur tutorials are amazing
@andrewclarke6916
@andrewclarke6916 4 жыл бұрын
Thanks for this, Brad. Really looking forward to this series. It will probably involve you having to explain some concepts with diagrams though, which you're not so keen on doing.
@CoderArchive
@CoderArchive 3 жыл бұрын
awesome! data structures are important to know about like hash tables, I'm looking forward to more 💯
@albertograu3318
@albertograu3318 4 жыл бұрын
Great stuff Brad, keep them coming :)
@credonduhura7121
@credonduhura7121 3 жыл бұрын
Thanks for starting this series Brad!! it's very important stuff to know as a programmer, as you mentionned. Can you please make a udemy course for algorithms and data structures
@sardorjumanazarov441
@sardorjumanazarov441 4 жыл бұрын
awesome Brad. I like all lessons, pls keep going
@valentin.berlin
@valentin.berlin 4 жыл бұрын
Thank you, Brad, very clear explanation. I think it's a great topic. In future videos, could you also include examples of some use cases for the structures you cover?
@retr0477
@retr0477 4 жыл бұрын
Wow please keep releasing these Data Structures & Algorithms videos. I really appreciate it bro
@smartydude2157
@smartydude2157 4 жыл бұрын
That's so awesome 😍 i think Actually my Law of Attraction has worked out.. I was daily searching for great whole algorithm series and finally got it 😊😊😀
@amjadsalah5193
@amjadsalah5193 4 жыл бұрын
Thank you 🙏, and if there is a series on algorithms this will be helpful 👌😁😁
@CodingWithMrM
@CodingWithMrM 2 жыл бұрын
Thanks it's really helpful for me
@RyanRoat
@RyanRoat 4 жыл бұрын
The BaseCS podcast has a number of episodes on data structures. They provided a great description of the stack - a spring loaded dish stacker in a cafeteria. The cafeteria pushes the dishes onto the stack, and the diners pop them off when they queue up. Oh, look, there's another data structure. :) And yes, I'd like a look at tests to verify the stack is working as expected.
@andrewiglinski148
@andrewiglinski148 4 жыл бұрын
Dude I was just messing with react-navigator for react native when I saw this. As soon as I saw this I kind of pee'd a little from overwhelming excitement.
@ahmedboutaraa8771
@ahmedboutaraa8771 4 жыл бұрын
Am was eagerly waiting for more of data structure
@arielspalter7425
@arielspalter7425 3 жыл бұрын
Awesome tutorial, thank you!
@kumarraja1989
@kumarraja1989 3 жыл бұрын
Nice explanation with good examples
@rasulyakubov1461
@rasulyakubov1461 4 жыл бұрын
I think a new ERA is going to begin for Traversy Media Students and for Brad too :)
@trainfansofindia
@trainfansofindia 4 жыл бұрын
Awesome video... concepts are very clear.
@18nikhilchauhan80
@18nikhilchauhan80 3 жыл бұрын
Loved it Brad ❤️
@fliporfail6115
@fliporfail6115 4 жыл бұрын
Good vid as always 🙏🏾
@somethingstupidlikeiloveu
@somethingstupidlikeiloveu 4 жыл бұрын
It's always amazing to have you
@TraversyMedia
@TraversyMedia 4 жыл бұрын
Thanks :)
@judeokagu6757
@judeokagu6757 4 жыл бұрын
Finally 😀 Brad to the world 🌎
@timurgolovinov
@timurgolovinov 3 жыл бұрын
It would be great if you can also explain where they can be useful in real-world applications, please Brad!
@Saurabh5989
@Saurabh5989 4 жыл бұрын
Thank you so much Brad :)
@swarnalathavura1334
@swarnalathavura1334 4 жыл бұрын
I'm new to this channel recently I joined but it's very nice waiting for more videos I'll support u
@radnerus93
@radnerus93 4 жыл бұрын
Happy that you started DS❣️
@ogeobubu9434
@ogeobubu9434 3 жыл бұрын
Thank so much for this. Well explained and totally understandable. I hope you see this but this is kinda a reminder of the promise sir to make this an ongoing series. I look forward to seeing Queue, Binary Search Tree and others. Thanks in anticipation :-)
@cubedev4838
@cubedev4838 3 жыл бұрын
Please continue this kind of series
@ravimone1
@ravimone1 4 жыл бұрын
Brad, thank you very much, you are the best, thanks for continuing your DS series, actually I sent message in twitter for the same
@chhumchanleak7642
@chhumchanleak7642 2 жыл бұрын
Thank you for this
@ephantusokumu7742
@ephantusokumu7742 4 жыл бұрын
Thanks Brad the beast!!
@jaleotech5918
@jaleotech5918 4 жыл бұрын
pop in the example not actually removing anything.. if you con log items they are all still there. The only thing that is going on is the changing of the counter not the actual array..
@mykalimba
@mykalimba 4 жыл бұрын
Why does it matter? It is _effectively_ removed, from the perspective of whoever is using the API for this class.
@vegitax
@vegitax 4 жыл бұрын
@@mykalimba no, it's not. It matters a lot because the values are still in the memory and only the 'pointer' moves and that's not how a stack should work. If this was in a production env somewhere it would undoubtly cause problems at some point.
@vegitax
@vegitax 4 жыл бұрын
It bothered me for the whole video that the values were not deleted. I was waiting for the whole time for Brad to notice it because he usually does 😅
@kumarraja1989
@kumarraja1989 3 жыл бұрын
Exactly, I am looking for the solution
@norricobiason5821
@norricobiason5821 3 жыл бұрын
@@mykalimba you want to see how isn't popping element in the stack? insert this in pop() method let deleteItem = this.items[this.count - 1]; this.count -= 1; console.log(`${deleteItem} removed`); console.log(`${this.items}`);
@tom.watkins
@tom.watkins 4 жыл бұрын
Great video. Only thing I was expecting was the pop method to reduce the size of the internal array
@sergiyrudenko905
@sergiyrudenko905 3 жыл бұрын
Great Thanks!!! Please make full data structure course I need it.
@NaveenRawat51
@NaveenRawat51 3 жыл бұрын
Hi Brad, you are awesome. in pop method i think you need to mutate the items array also by removing the last element. thanks
@leod.9343
@leod.9343 3 жыл бұрын
We want more data structures and algos ! Please Brad !
@srivatsanramesh1739
@srivatsanramesh1739 4 жыл бұрын
Hello Brad.. I have a question. When you’re popping an element from the stack, the element doesn’t actually go out of the ‘items’ array right..? It’s still there. Though you decrement the ‘count’ variable... shouldn’t the element be actually going out of the array..? Do correct me if I’m wrong.
@dmitrydomanski708
@dmitrydomanski708 4 жыл бұрын
The same question I was going to make
@mykalimba
@mykalimba 4 жыл бұрын
Why does it matter? It is _effectively_ removed, from the perspective of whoever is using the API for this class.
@tanieltari4539
@tanieltari4539 4 жыл бұрын
@@mykalimba It does matter - you are using less CPU cycles and so your code will be faster. Time spent will be actually noticeably lower, just test it yourself
@michaelwilson1771
@michaelwilson1771 3 жыл бұрын
Technically not a memory leak, although the array doesn't shrink after pop. Javascript makes it a little harder to create true leaks due to garbage collection. The array size will only ever be as large as the number of successive push items. After pop, those items will still be in memory, but future pushes will overwrite them. The element references aren't actually lost. Just technically not 'efficient' in memory usage. Push 100 items - array size == 100. Pop 100 items - array size ==100. Push 100 more items - array size == 100. Also keep in mind @traversymedia was just trying to demonstrate how a stack works. You could do this just as easily with a straight Array using unshift() and pop()
@rtorcato
@rtorcato 3 жыл бұрын
The next series will be how to deal with memory leaks
@eduriseworld
@eduriseworld 4 жыл бұрын
Awesome awesome. I'm going to start videos on Leetcode problems as well. Have my Facebook interview on 8th. Will definitely check these DS videos of yours. :)
@eduriseworld
@eduriseworld 4 жыл бұрын
BTW All, Facebook Enterprise Team is hiring like crazy at the moment. Pick a Facebook Recruiter from LinkedIn and send them a message that you want to join the "Enterprise Team", they will hook you up with the right department. Feel free to ask me if you need help. Can't help you get an interview right away, but can definitely guide the way in which you can get an interview. I don't work at Facebook (yet!)
@tomershechner7449
@tomershechner7449 4 жыл бұрын
@@eduriseworld Good luck man, let us all now when you get hired! (maybe you'll replace Zuckerberg, who knows ;D ?)
@LabaranLabs
@LabaranLabs 4 жыл бұрын
@@tomershechner7449 sure
@magedhanafy9010
@magedhanafy9010 4 жыл бұрын
Yes, please do a video on proper testing
@feruttin
@feruttin 3 жыл бұрын
Hi, you could start this.count = -1 and increment it before assigning. so there will not be mess with indexes.
@arjunkashyap8896
@arjunkashyap8896 4 жыл бұрын
I know stack and other DS but I'll still watch this series..
@andylib
@andylib 3 жыл бұрын
Hell yeah 🔥
@alimanzoor2359
@alimanzoor2359 3 жыл бұрын
as usual awesome, bro if possible kindly make a video on React + immer
Top 10 Javascript Algorithms to Prepare for Coding Interviews
1:52:53
freeCodeCamp.org
Рет қаралды 54 М.
STOP Using Classes In JavaScript | Prime Reacts
14:02
ThePrimeTime
Рет қаралды 207 М.
Não pode Comprar Tudo 5
00:29
DUDU e CAROL
Рет қаралды 84 МЛН
Кәріс тіріма өзі ?  | Synyptas 3 | 8 серия
24:47
kak budto
Рет қаралды 1,3 МЛН
Complete Guide to JS Sets: How They Work & When To Use Them
18:38
CSS Grid Layout With Image Span
13:38
Traversy Media
Рет қаралды 148 М.
You might not need useEffect() ...
21:45
Academind
Рет қаралды 128 М.
Are You Too Dumb To Code? A Chat About Imposter Syndrome
7:08
Traversy Media
Рет қаралды 61 М.
Express Crash Course (2024 Revamp)
1:46:11
Traversy Media
Рет қаралды 14 М.
Build Minesweeper with JavaScript
48:06
Traversy Media
Рет қаралды 126 М.
Binary Tree Algorithms for Technical Interviews - Full Course
1:48:53
freeCodeCamp.org
Рет қаралды 679 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 571 М.
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 22 М.
Он Отказался от БЕСПЛАТНОЙ видеокарты
0:40
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 326 М.
Phone charger explosion
0:43
_vector_
Рет қаралды 41 МЛН
Photo editing changing Boder Work solution New tools
0:52
UNIQUE PHOTO EDITING
Рет қаралды 219 М.
Что еще за обходная зарядка?
0:30
Не шарю!
Рет қаралды 666 М.