About 1 hour
JS Functional programming
Stack is one of the most commonly used data structure along with its opposite relative, queue. Understanding how to implement stack helps you better understand and describe insertion, removal, and organization of data in a seqential order.
Explain what a stack data structure is and show how it is implemented.
- Definition of stack
- Show an example of stack data structure
- JavaScript methods used to implement stack
- GeeksforGeeks: Implementation of Stack in JavaScript
- InitJS: Implement a Stack in JavaScript
- Cloudboost: Data Structures in JavaScript: Stacks & Queues
- Lesson slides: https://docs.google.com/presentation/d/1lOqqqXF-NYzFw0Cu3vIa-dLZeERGhcg1SFmOgW4Y62w/edit#slide=id.p
- Lesson video: https://drive.google.com/open?id=1ioFhuH4I0J5gAnwyw6SJxWzioAWKNrZp
Make sure to mention these things:
- Explain what LIFO and FILO means.
- Differentiate stack and queue.
- Array and stack seem similar at first glance. While stack can be implemented using array, the data in array can be access randomly whereas stack must be access according to order.
Explain and discuss as a class the steps involved in writing a stack structure, including:
- Constructor
- Push/Enqueue
- Pop/Dequeue
- Size control
Try to write a Stack class with the steps discuss as methods:
var Stack = function() {}
// Constructor
// Push
// Pop
// Size management of stack
// Output of stack
}
Find a partner and show each other your own Stack class. Explain how the class you wrote works.