1
00:00:00,550 --> 00:00:01,510
Hi everyone.

2
00:00:01,510 --> 00:00:04,330
In this video let's talk about two questions.

3
00:00:04,330 --> 00:00:06,940
The first question is what are data structures?

4
00:00:06,940 --> 00:00:11,890
And the second question is why do you need to learn them to ace coding interviews.

5
00:00:11,890 --> 00:00:12,370
All right.

6
00:00:12,370 --> 00:00:14,290
So let's get started with the first question.

7
00:00:14,290 --> 00:00:21,160
What are data structures now as per Wikipedia, data structures are just a collection of data values

8
00:00:21,610 --> 00:00:24,100
and relationships among them.

9
00:00:24,490 --> 00:00:29,290
And the functions or operations that can be applied to the data.

10
00:00:29,290 --> 00:00:32,350
So this is what Wikipedia defines data structures to be.

11
00:00:32,350 --> 00:00:38,380
Now let's take these three components of the definition and try to understand what data structures are.

12
00:00:38,410 --> 00:00:42,400
For this let's take a very familiar data structure which is arrays.

13
00:00:42,400 --> 00:00:44,980
So let's say this is an array which we have.

14
00:00:44,980 --> 00:00:47,140
So you can see it has four values in it.

15
00:00:47,140 --> 00:00:53,170
Now over here if you look at this array over here you can agree that this is a collection of data values.

16
00:00:53,170 --> 00:00:55,780
So we have a check mark to the first condition over here.

17
00:00:55,780 --> 00:00:58,960
So the data values over here are 156 and eight.

18
00:00:58,990 --> 00:01:03,040
Now we can also see that there are relationships among these data values.

19
00:01:03,040 --> 00:01:03,940
Now what is it.

20
00:01:03,940 --> 00:01:09,400
For example in the case of arrays we have the indices over here zero, one two and three.

21
00:01:09,400 --> 00:01:12,610
So yes there is a relationship between these two values right.

22
00:01:12,610 --> 00:01:15,040
For example this is the value before.

23
00:01:15,040 --> 00:01:19,240
This value over here is before this because this is index zero and this is index one.

24
00:01:19,240 --> 00:01:21,970
So there is a relationship among these data values.

25
00:01:21,970 --> 00:01:26,530
And then finally there are functions or operations that can be applied to them.

26
00:01:26,530 --> 00:01:26,980
Right.

27
00:01:26,980 --> 00:01:29,860
Or let's say we have we call this array over here.

28
00:01:29,860 --> 00:01:30,280
Ah.

29
00:01:30,280 --> 00:01:33,670
So we let's say we say const r is equal to 1568.

30
00:01:33,670 --> 00:01:35,740
So the array over here is called r.

31
00:01:35,770 --> 00:01:41,350
Now if we want to push another value to the array we can say r dot push and then give the value right.

32
00:01:41,350 --> 00:01:44,440
So this is actually a function which is inbuilt.

33
00:01:44,440 --> 00:01:47,860
And this can do operations on the array which is given to us.

34
00:01:47,860 --> 00:01:51,310
So that's why we can say an array is a data structure.

35
00:01:51,310 --> 00:01:56,740
And in fact an array is a pre-built data structure which is there in almost every programming language.

36
00:01:56,740 --> 00:01:59,770
And definitely it is there pre-built in JavaScript.

37
00:01:59,770 --> 00:02:06,670
Now we will also be coding and building some of some other data structures from scratch as we go ahead

38
00:02:06,670 --> 00:02:07,600
with this course.

39
00:02:07,600 --> 00:02:12,700
So we are done and we have understood the first question, which is what are data structures?

40
00:02:12,700 --> 00:02:18,850
Now let's go to the second question, which is why do you need to learn data structures to be able to

41
00:02:18,850 --> 00:02:20,350
ace coding interviews?

42
00:02:20,350 --> 00:02:27,490
So in coding interviews we will be given some input and we will be asked to write an algorithm that

43
00:02:27,490 --> 00:02:31,990
can manipulate the input which is given to us to arrive at the desired output.

44
00:02:31,990 --> 00:02:35,740
So this is basically what coding interviews is all about right now.

45
00:02:35,740 --> 00:02:38,950
The input and the output is actually just data.

46
00:02:38,950 --> 00:02:40,990
So you would be given some data.

47
00:02:40,990 --> 00:02:43,480
You write an algorithm to get the result right.

48
00:02:43,480 --> 00:02:48,880
For example, let's say you're given two numbers A and B and the algorithm is to add these two numbers

49
00:02:48,880 --> 00:02:49,690
a plus b.

50
00:02:49,690 --> 00:02:54,280
And the output that you're getting is the sum, which is let's say sum is equal to a plus b.

51
00:02:54,280 --> 00:02:56,590
So the output is the sum which is s right.

52
00:02:56,590 --> 00:02:58,930
So this is actually a very simple algorithm.

53
00:02:58,930 --> 00:03:02,440
And again every coding interview question follows this pattern.

54
00:03:02,440 --> 00:03:08,110
Now when you take a look at questions in which come up in the coding interviews, you can solve these

55
00:03:08,110 --> 00:03:10,030
questions in multiple ways.

56
00:03:10,030 --> 00:03:14,980
So that means you can write different algorithms and you can get the required output.

57
00:03:14,980 --> 00:03:21,040
But then there are some data structures that are more efficient than others to do some tasks.

58
00:03:21,040 --> 00:03:26,320
So what do we mean with more efficient now because we are dealing with computers, efficiency over here

59
00:03:26,320 --> 00:03:32,410
means it may take some algorithms, may take less time to solve the question, or some algorithms may

60
00:03:32,410 --> 00:03:34,810
take less space to solve the question.

61
00:03:34,810 --> 00:03:35,200
All right.

62
00:03:35,200 --> 00:03:42,430
So that's why it's very important to have a hands on understanding with all the common data structures

63
00:03:42,430 --> 00:03:47,680
to be able to solve coding interview questions in the best or in an efficient manner.

64
00:03:47,680 --> 00:03:50,920
So you have to be hands on with the common data structures.

65
00:03:50,920 --> 00:03:56,290
You have to know their positives and negatives of different data structures, and what data structure

66
00:03:56,290 --> 00:03:59,590
is suitable for different types of scenarios or tasks.

67
00:03:59,590 --> 00:04:06,160
Now, the good news is that the number of common data structures is pretty well defined, and you can

68
00:04:06,160 --> 00:04:11,050
easily get hands on and good with these data structures in a short period of time.

69
00:04:11,050 --> 00:04:12,280
So let's go ahead.

70
00:04:12,280 --> 00:04:17,740
And in this course, as we see as we get introduced to new data structures, we will try to learn the

71
00:04:17,740 --> 00:04:18,760
theory behind them.

72
00:04:18,760 --> 00:04:22,240
We will have crash courses on those specific data structures.

73
00:04:22,240 --> 00:04:28,300
We will try to analyze the Big-O complexity with respect to time and space for various actions or operations.

74
00:04:28,300 --> 00:04:33,850
And we will learn as we keep going on with the course, what data structure to use for what type of

75
00:04:33,850 --> 00:04:34,390
questions.
