DEV Community

Play Button Pause Button
Vaidehi Joshi
Vaidehi Joshi

Posted on

Stacks and Queues — BaseCS Video Series

"Stack level too deep!"

Stacks and queues are all around us. In this video we break down what they are, how they work, and their place in every day software development.

For more on Stacks and queues, check out this post:

If you have questions or comments, please feel free to share below.

SparkPost Logo

This video series is sponsored by SparkPost. There's never been a better way for developers to send email.

Top comments (17)

Collapse
 
jinhuiwong profile image
Wong •

Wonderful!

Collapse
 
nelsonrodrigues profile image
Nelson Rodrigues •

Loving this series! I'm a visual learner so this style is just perfect for me!

Collapse
 
philsinsight profile image
Mr. Boateng •

Great video, really appreciated the illustrations 👌🏾

Collapse
 
codemouse92 profile image
Jason C. McDonald •

Really great videos! Even though I'm well familiar with these concepts, it was a good reminder, and I have half a page of notes for expanding and improving my company's high-efficiency implementations.

Collapse
 
nickytonline profile image
Nick Taylor •

I took CS in university, but I'm really enjoying this series. It's so well done. I love your drawings. They really help the concepts sink in for viewers. Looking forward to the next one. Keep up the great work Vaidehi!

Collapse
 
ben profile image
Ben Halpern •

Wonderful episode. Welcome back Vaidehi!

Collapse
 
andy profile image
Andy Zhao (he/him) •

Awesome video!

Collapse
 
samsonasik profile image
Abdul Malik Ikhsan •

Awesome, Thank you!

Collapse
 
brwerme profile image
RHRup •

Thanks 🙏 vaidehi joshi ...really appreciating for helping to learn and giving confident on understanding i can do it👩🏻‍🎓☺️

Collapse
 
nonsobiose profile image
Nonso Biose •

Hey, when you say an Array is a static Data Structure, I understand, coz in Java an array is created with an initial size. But in javaScript, arrays are dynamic. So can't see implement a stack using arrays in JavaScript.

Collapse
 
namirsab profile image
Namir •

You can easily do it with arrays. A small example:

class Stack {
    constructor() {
        this.stack = [];
    }
    push(element) {
        this.stack.push(element);
    }
    top() {
        return this.stack[this.stack.length - 1];
    }

    pop() {
        return this.stack.pop();
    }

    toArray() {
        return Array.from(this.stack);
    }

    isEmpty() {
        return this.stack.length === 0;
    }
}

You could tune it a bit to check for a maximum size or stuff like that :)

Collapse
 
nonsobiose profile image
Nonso Biose •

Thanks. But in this way, the stack can never get filled up, coz the array ain't static. I think different languages, have their different implementation of abstract structures. In java, you can't implement a stack with an array coz its fixed

Thread Thread
 
namirsab profile image
Namir •

You can always "fix" the array if you want by adding a size to the constructor. Then you check if the size is met whenever you push a new value to the stack. So yeah, the language can give you other constructs and other ways to do something, but it's totally possible to do it in JavaScript

Thread Thread
 
nonsobiose profile image
Nonso Biose •

Thanks man