1

00:00:00,960  -->  00:00:04,670
Let's not look at other tech and we will also get them off it.

2

00:00:04,770  -->  00:00:12,900
We would see its usage as boutique Q as well as a stock as the name implies it is an implementation

3

00:00:12,990  -->  00:00:15,970
of a direct interface and is resizable.

4

00:00:16,500  -->  00:00:20,820
So internally it uses an Id just like an idealist.

5

00:00:21,090  -->  00:00:26,330
It was added in July 6 which means that it is a fairly new data structure.

6

00:00:26,760  -->  00:00:31,420
And since it is a deck we know that it can it both before and before.

7

00:00:32,160  -->  00:00:33,430
And these are the different ways.

8

00:00:33,500  -->  00:00:40,710
Creating an idyllic it can be unbonded or you can specify a fixed capacity or you can also construct

9

00:00:40,710  -->  00:00:44,670
it with the elements from the specified collection.

10

00:00:45,260  -->  00:00:51,270
Not that unlike a linked list which is also a deck other deck prohibits null values.

11

00:00:51,290  -->  00:00:58,890
Ok so you cannot add an old values and similarly unlikely English it does not implement the list interface

12

00:00:58,910  -->  00:00:59,150
.

13

00:00:59,460  -->  00:01:03,120
So it is a pure Q implementation.

14

00:01:03,120  -->  00:01:05,230
Novin we need to use a better implementation.

15

00:01:05,250  -->  00:01:09,230
It is recommended to use an Arabic rather than a linked list.

16

00:01:09,410  -->  00:01:11,340
And here are some reasons for that.

17

00:01:11,340  -->  00:01:13,640
One of them is from Java dock itself.

18

00:01:13,900  -->  00:01:20,310
It says that it is likely that an array deck is faster than linguist's if the linked list is used as

19

00:01:20,310  -->  00:01:22,350
a queue.

20

00:01:22,410  -->  00:01:28,030
There is also an article whose link is provided in the resources section and it proves that Arek is

21

00:01:28,040  -->  00:01:32,520
at on three times faster than a linked list for large groups.

22

00:01:32,520  -->  00:01:39,810
The main reason for that is that link list we have to create an additional node object with every newly

23

00:01:39,810  -->  00:01:41,510
added element right.

24

00:01:41,550  -->  00:01:48,000
We saw that in the linked list lecture that would take more time and would also mean more memory footprint

25

00:01:48,000  -->  00:01:48,990
.

26

00:01:48,990  -->  00:01:52,950
Similarly when the element is remote the object needs to be garbage collected.

27

00:01:53,140  -->  00:01:59,160
And so if there are a lot of elementary movers then it will load on the DC process.

28

00:01:59,280  -->  00:02:04,830
Also if you do a bit of hard thinking you make definitely come across this dot right.

29

00:02:04,830  -->  00:02:11,520
Why cant we use an idealist as if fearful we simply need to use the odd method for adding an element

30

00:02:11,520  -->  00:02:16,850
of pain and the removal of zero for removing the element from the head.

31

00:02:17,430  -->  00:02:23,070
There are few good reasons why you should not use another list on other deck would still be our best

32

00:02:23,070  -->  00:02:25,930
bet for you.

33

00:02:26,140  -->  00:02:28,170
One reason is performance.

34

00:02:28,170  -->  00:02:35,160
We know that in working remote off zero on an oral test which if all the subsequent elements.

35

00:02:35,160  -->  00:02:41,900
So it has a linear time complexity and it only gets back with a large number of elements because we

36

00:02:41,910  -->  00:02:44,580
how more and more dimensions.

37

00:02:45,150  -->  00:02:50,600
In fact according to one benchmark linked list was 20 times faster than our list product foredeck do

38

00:02:50,600  -->  00:02:58,130
you like Access 2000 elements who are used so Elliman chefs is definitely a killer.

39

00:02:58,530  -->  00:03:02,420
Link to the benchmark is included in the resources section.

40

00:03:02,970  -->  00:03:10,020
So you might next ask what about the men chef in an article as it is also at based base just like an

41

00:03:10,080  -->  00:03:11,230
idealist.

42

00:03:11,610  -->  00:03:17,340
We dont have 11 shifts bit with a deck as its implementation is based on something called its circular

43

00:03:17,360  -->  00:03:21,050
area which does not in ball and dimensions.

44

00:03:21,140  -->  00:03:21,540
OK.

45

00:03:21,630  -->  00:03:25,120
So it has more to do with the algorithm to make logic.

46

00:03:25,470  -->  00:03:31,180
So it would be constant time for adding and removing at both ends.

47

00:03:31,200  -->  00:03:37,680
Now another reason why idealists should not be used as a cue is your intention from a design perspective

48

00:03:37,690  -->  00:03:37,840
.

49

00:03:37,980  -->  00:03:44,190
Indention been using a red deck is to use it as a fee for Ardsley for which involves on the head or

50

00:03:44,190  -->  00:03:50,500
tail manipulations method names like pop beak and push very clearly reflect that.

51

00:03:51,030  -->  00:03:59,460
But with other list we did not constrain ourselves to or meet her dentate right under the complexities

52

00:03:59,460  -->  00:04:00,320
of the methods.

53

00:04:00,510  -->  00:04:07,950
Most methods run in a monetised Constantine that is then mostly constant time summiteers that deal with

54

00:04:07,950  -->  00:04:14,230
the remolding are searching for specific objects one billion years as we know because Can that you not

55

00:04:14,250  -->  00:04:19,750
that here we are talking about the remote off object method and not the moment.

56

00:04:19,840  -->  00:04:23,110
But empty parenthesis which is constant.

57

00:04:23,700  -->  00:04:30,630
Finally keep in mind that there is no way for us to add something in the middle Ah-Q all the internal

58

00:04:30,630  -->  00:04:34,710
elements can be deleted using these at the moment it's that busy here.

59

00:04:35,220  -->  00:04:36,390
So that's about it.

60

00:04:36,390  -->  00:04:40,580
No let's go ahead and Bushrod them off autistic.

61

00:04:41,910  -->  00:04:45,580
OK for this demo we're going to add a new class called that's cute.

62

00:04:45,610  -->  00:04:47,770
All of it is added to this package.

63

00:04:47,790  -->  00:04:54,620
Class collections that you deem a class has a motet deck test which we are going to fill in now.

64

00:04:54,870  -->  00:05:00,450
So it does not mean we are going to create an instance of our deck and we will use it as both a queue

65

00:05:00,570  -->  00:05:01,700
as well as us duck.

66

00:05:01,900  -->  00:05:04,290
OK so let's just go ahead and do that.

67

00:05:05,010  -->  00:05:13,950
So the reference type would be deck under deck which stored on these strings.

68

00:05:14,970  -->  00:05:18,550
Case select mean book already on deck.

69

00:05:20,240  -->  00:05:23,260
Now let's just go ahead and add some elements.

70

00:05:23,310  -->  00:05:24,720
So first let's do.

71

00:05:25,060  -->  00:05:26,550
Let's use it as a Q.

72

00:05:26,690  -->  00:05:32,820
OK which is official.

73

00:05:34,320  -->  00:05:36,460
Let's try to have some books here.

74

00:05:36,530  -->  00:05:37,930
That's our first book.

75

00:05:37,960  -->  00:05:40,620
Wilden a very nice book.

76

00:05:41,160  -->  00:05:50,100
A nineteenth century classic and lets out Harry Potter.

77

00:05:52,800  -->  00:06:00,740
And finally let's ired head first Java which is a great beginner level book quarte Java and there's

78

00:06:00,750  -->  00:06:03,680
also the commander and this course.

79

00:06:03,690  -->  00:06:13,650
Now let's put this statement here and let's say branding.

80

00:06:13,680  -->  00:06:18,780
Q And let's pretend all that three books.

81

00:06:18,840  -->  00:06:25,080
OK so this all goes space nuts.

82

00:06:25,140  -->  00:06:31,240
So we need to remove from the head and for that we know we can use the remote method.

83

00:06:31,530  -->  00:06:32,810
Right.

84

00:06:33,660  -->  00:06:36,710
So that would remove the element on would also get on that end.

85

00:06:36,810  -->  00:06:40,970
So let's call this let's do it.

86

00:06:41,010  -->  00:06:43,890
The second element also has the third element.

87

00:06:44,340  -->  00:06:50,460
Now it can be removed or you can also use it to move fast.

88

00:06:50,460  -->  00:06:50,800
Right.

89

00:06:50,820  -->  00:06:52,730
Because I've just got a Spawn's to head.

90

00:06:53,280  -->  00:06:55,480
So you just go ahead and run this.

91

00:06:55,540  -->  00:06:58,730
This method is and will Crome the main method.

92

00:06:58,970  -->  00:07:00,790
So it is bending the elements.

93

00:07:00,900  -->  00:07:06,540
So the first element that got added was Brandon underspending round and then the second element then

94

00:07:06,540  -->  00:07:07,350
the third element.

95

00:07:07,400  -->  00:07:09,420
OK so that is powerful.

96

00:07:09,700  -->  00:07:14,040
Now let's go ahead and also do the same for a stack.

97

00:07:14,040  -->  00:07:15,230
So let's implement as a stack.

98

00:07:15,270  -->  00:07:19,400
So at this point the deck is empty because we removed all the elements that what I did.

99

00:07:19,650  -->  00:07:21,860
So we can just reuse the same deck.

100

00:07:22,110  -->  00:07:30,240
I let's use it as a stack so let's just say stack last and just out.

101

00:07:30,330  -->  00:07:33,500
Now let's go ahead and push the same elements.

102

00:07:33,540  -->  00:07:33,750
OK.

103

00:07:33,750  -->  00:07:36,720
So let's use a push method.

104

00:07:37,980  -->  00:07:40,920
Don't push it

105

00:07:40,950  -->  00:07:51,770
.

106

00:07:51,860  -->  00:07:52,230
OK.

107

00:07:52,230  -->  00:07:56,500
So the elements have been pushed now to remove the elements.

108

00:07:56,490  -->  00:07:58,660
We can just use the pop method.

109

00:07:58,950  -->  00:08:05,060
So let me just copy this.

110

00:08:05,760  -->  00:08:10,540
This time it would be stuck.

111

00:08:12,720  -->  00:08:15,660
So here we just say pop

112

00:08:20,930  -->  00:08:26,780
that Sir sort of says go ahead and run it.

113

00:08:27,420  -->  00:08:30,370
Now as you can see the elements are the stack.

114

00:08:30,370  -->  00:08:33,900
They're getting pretty good in the reverse order because it doesn't last.

115

00:08:33,940  -->  00:08:35,170
And fast.

116

00:08:35,580  -->  00:08:39,150
So the last N elementals head first Java and that is garding.

117

00:08:39,200  -->  00:08:40,980
Bob don't just.

118

00:08:41,280  -->  00:08:42,420
So that's it.

119

00:08:42,420  -->  00:08:48,900
So stack is something we have already seen ret in GBM also the IBM also implements its metor in most

120

00:08:48,900  -->  00:08:50,290
patients using iStock.

121

00:08:50,540  -->  00:08:52,920
OK on is also used in many places.

122

00:08:52,950  -->  00:08:58,930
It's also used in a framework called Executive framework which you will see in the collections Shapter

123

00:08:59,460  -->  00:09:05,790
which is used to manage the threats threat management third management there the executive framework

124

00:09:05,850  -->  00:09:07,370
makes use of a.

125

00:09:07,530  -->  00:09:08,020
OK.

126

00:09:08,070  -->  00:09:10,980
So you is also used.

127

00:09:10,980  -->  00:09:11,910
So that's about it.

128

00:09:11,940  -->  00:09:13,170
So these are the things.

129

00:09:13,310  -->  00:09:18,950
And we also know that a linked list also implements direct interface.

130

00:09:19,280  -->  00:09:21,530
In addition to a list.

131

00:09:21,540  -->  00:09:23,940
So if we can import this

132

00:09:26,970  -->  00:09:28,220
and see the same output.

133

00:09:28,320  -->  00:09:30,180
So long list also can be used.

134

00:09:30,390  -->  00:09:35,460
But as we discussed earlier if you want a deck implementation you should go get utterer dick.

135

00:09:35,550  -->  00:09:37,910
OK so that's the recommended approach.

136

00:09:38,020  -->  00:09:40,020
Is that a commander implementation.

137

00:09:40,050  -->  00:09:40,680
So that's about it.

138

00:09:40,680  -->  00:09:41,160
Thank you.

139

00:09:41,160  -->  00:09:45,210
And you can find this code in the resources section and that's it.

140

00:09:45,210  -->  00:09:46,520
I'm happy coding.
