Hi there! How are you? I hope you are doing fine..
Well, what is a programmer who doesn’t know the CS fundamentals, right? Well, in order to level up you need to know some of these concepts! Even if you are autodidact like me, at some point the questions arise.. So, in this post we will explore some of the basic data structures that I am sure you all use every day but some of you (like me) do not know the basic notions behind them!
Stack
A stack is a basic data structure that can be illustrated by thinking of your data set as a stack of books where you can only take the top item off the stack in order to remove things from it. Further on, if you add a book in the stack it has to go on top of it.
There are basically three operations that can be performed on stacks.
- inserting (“pushing”) an item into a stack
- deleting (“popping”) an item from the stack
- displaying the contents of the top item of the stack (“peeking”)
Queue
A queue is linear data structure, in which the first element is inserted from one end (the “tail”), and the deletion of existing element takes place from the other end (the “head”). An example of a queue is a real queue of people waiting in line for a movie or in the bank.
The process of adding an element to a queue is called “enqueuing” and the process of removing an element from a queue is called “dequeuing”.
For those of you with a finance or business background (like me) you can use the terms of LIFO and FIFO for Stack and Queue respectively! LIFO means “Last-In, First-Out” and FIFO “First-In, First-Out”.
A very famous Queue is the Event Loop in JavaScript. You can check it out on Mozilla MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop
Finally, this is not an exhaustive list of the basic data structures someone can find but rather a mem note for me to remember.
Cheers!
2 comments
Beberone
November 23, 2017 at 1:02 pm
I like the link with finance/business…very good explanation!
gd
November 23, 2017 at 2:18 pm
Once again thanks for the nice comment! 🙂