Hi everyone.
In this video let's talk about two questions.
The first question is what are data structures?
And the second question is why do you need to learn them to ace coding interviews.
All right.
So let's get started with the first question.
What are data structures now as per Wikipedia, data structures are just a collection of data values
and relationships among them.
And the functions or operations that can be applied to the data.
So this is what Wikipedia defines data structures to be.
Now let's take these three components of the definition and try to understand what data structures are.
For this let's take a very familiar data structure which is arrays.
So let's say this is an array which we have.
So you can see it has four values in it.
Now over here if you look at this array over here you can agree that this is a collection of data values.
So we have a check mark to the first condition over here.
So the data values over here are 156 and eight.
Now we can also see that there are relationships among these data values.
Now what is it.
For example in the case of arrays we have the indices over here zero, one two and three.
So yes there is a relationship between these two values right.
For example this is the value before.
This value over here is before this because this is index zero and this is index one.
So there is a relationship among these data values.
And then finally there are functions or operations that can be applied to them.
Right.
Or let's say we have we call this array over here.
Ah.
So we let's say we say const r is equal to 1568.
So the array over here is called r.
Now if we want to push another value to the array we can say r dot push and then give the value right.
So this is actually a function which is inbuilt.
And this can do operations on the array which is given to us.
So that's why we can say an array is a data structure.
And in fact an array is a pre-built data structure which is there in almost every programming language.
And definitely it is there pre-built in JavaScript.
Now we will also be coding and building some of some other data structures from scratch as we go ahead
with this course.
So we are done and we have understood the first question, which is what are data structures?
Now let's go to the second question, which is why do you need to learn data structures to be able to
ace coding interviews?
So in coding interviews we will be given some input and we will be asked to write an algorithm that
can manipulate the input which is given to us to arrive at the desired output.
So this is basically what coding interviews is all about right now.
The input and the output is actually just data.
So you would be given some data.
You write an algorithm to get the result right.
For example, let's say you're given two numbers A and B and the algorithm is to add these two numbers
a plus b.
And the output that you're getting is the sum, which is let's say sum is equal to a plus b.
So the output is the sum which is s right.
So this is actually a very simple algorithm.
And again every coding interview question follows this pattern.
Now when you take a look at questions in which come up in the coding interviews, you can solve these
questions in multiple ways.
So that means you can write different algorithms and you can get the required output.
But then there are some data structures that are more efficient than others to do some tasks.
So what do we mean with more efficient now because we are dealing with computers, efficiency over here
means it may take some algorithms, may take less time to solve the question, or some algorithms may
take less space to solve the question.
All right.
So that's why it's very important to have a hands on understanding with all the common data structures
to be able to solve coding interview questions in the best or in an efficient manner.
So you have to be hands on with the common data structures.
You have to know their positives and negatives of different data structures, and what data structure
is suitable for different types of scenarios or tasks.
Now, the good news is that the number of common data structures is pretty well defined, and you can
easily get hands on and good with these data structures in a short period of time.
So let's go ahead.
And in this course, as we see as we get introduced to new data structures, we will try to learn the
theory behind them.
We will have crash courses on those specific data structures.
We will try to analyze the Big-O complexity with respect to time and space for various actions or operations.
And we will learn as we keep going on with the course, what data structure to use for what type of
questions.