
Introduction
Acing a tech interview begins months, if not years before the interview takes place. There's a long list of required topics, such as operating systems, databases, and system design. However, one of the most important topics among all is data structures.
Data structures are just a way of storing data so that it may be accessed and modified quickly. There are many sorts of data structures, each of which is appropriate for a specific application. We'll look at two of these DS today: Stack and Tree. So let's get this party started.
Stack
Stack is a linear data structure with three major operations- PUSH, POP, and TOP for Insertion, deletion, and retrieving the top element, respectively.
Consider an empty long rectangular box containing some books. Suppose you bought a new book and put it in the box on top of the stack of books you already had. Which book do you think you'll be able to get out of the box first? It's, of course, the last book you inserted. This is what a stack looks like. The last element you inserted will be the first to pop out of the stack, i.e., it follows the LIFO(Last in, first out) property.
Diagrammatic Representation of a Stack