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!
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”)
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”.
Finally, this is not an exhaustive list of the basic data structures someone can find but rather a mem note for me to remember.