1
00:00:01,110 --> 00:00:01,810
Hello, everyone.

2
00:00:01,830 --> 00:00:07,080
So in the last video, I gave this question to you, you have to construct the mediumship and these

3
00:00:07,080 --> 00:00:07,790
are the elements.

4
00:00:07,800 --> 00:00:12,440
And then after constructing the minimum heap, you have to perform this, remove minimum function,

5
00:00:12,510 --> 00:00:14,850
you have to apply this removing and function twice.

6
00:00:15,630 --> 00:00:17,870
So now let's start discussing our solution.

7
00:00:18,210 --> 00:00:20,280
So minimum, keep the properties very simple.

8
00:00:20,460 --> 00:00:26,550
So raw data should be less then left value and raw data should also be less than the right value Raychelle

9
00:00:26,610 --> 00:00:26,940
value.

10
00:00:27,630 --> 00:00:29,520
So now let's start discussing the solution.

11
00:00:29,710 --> 00:00:32,930
So the first element is still Sawtell then six.

12
00:00:32,940 --> 00:00:36,300
So the six will go in the left hand side, then compare six and 12.

13
00:00:36,300 --> 00:00:39,090
So 12 will come here and six will come here.

14
00:00:39,300 --> 00:00:40,650
Now the next element is five.

15
00:00:40,860 --> 00:00:42,490
So five will go in this direction.

16
00:00:42,510 --> 00:00:44,120
Now compare five and six.

17
00:00:44,130 --> 00:00:48,450
So again we have to do swapping so six will come here and five will come here.

18
00:00:48,720 --> 00:00:52,290
Now the next element is hundred, so one that will go in this direction.

19
00:00:52,510 --> 00:00:53,890
Now the next element is one.

20
00:00:54,180 --> 00:00:55,290
So one will go.

21
00:00:55,290 --> 00:00:57,020
One will go in this direction.

22
00:00:57,030 --> 00:00:59,400
So compared to 11, again, we have to do something.

23
00:00:59,730 --> 00:01:01,110
So 12 will come here.

24
00:01:01,830 --> 00:01:02,700
When will come here?

25
00:01:02,970 --> 00:01:04,720
Now compare one and five.

26
00:01:04,739 --> 00:01:06,020
So again, you have to do something.

27
00:01:06,030 --> 00:01:08,700
So five will come here and one will come here.

28
00:01:09,210 --> 00:01:10,680
Now the next element is nine.

29
00:01:10,860 --> 00:01:12,600
So nine will go in this direction.

30
00:01:13,320 --> 00:01:14,580
So nine and six.

31
00:01:14,580 --> 00:01:15,490
So it is correct.

32
00:01:15,690 --> 00:01:17,010
Now the next element is zero.

33
00:01:17,250 --> 00:01:21,080
So zero will go in this direction now compared to zero and six.

34
00:01:21,090 --> 00:01:26,600
So you have to do swapping six will come here and zero will come here now compared to zero and one.

35
00:01:26,610 --> 00:01:27,930
So again, you have to do something.

36
00:01:28,230 --> 00:01:29,310
One will come here.

37
00:01:30,060 --> 00:01:30,910
Zero will come here.

38
00:01:30,930 --> 00:01:32,270
Now the next element is 14.

39
00:01:32,610 --> 00:01:34,440
So 14 will go in this direction.

40
00:01:34,470 --> 00:01:36,010
Now compare 14 and under.

41
00:01:36,210 --> 00:01:39,840
So again, you have to do something and it will come here and 14 will come here.

42
00:01:39,870 --> 00:01:41,390
Now compare 14 and five.

43
00:01:41,400 --> 00:01:42,300
So it is correct.

44
00:01:42,750 --> 00:01:44,580
So finally, what is our minimum here?

45
00:01:45,060 --> 00:01:48,070
So this is zero and then we have five.

46
00:01:48,930 --> 00:01:50,380
So here we have one.

47
00:01:50,760 --> 00:01:52,590
So here we have nine and six.

48
00:01:54,510 --> 00:02:02,310
So here we have 14, then we have 12, and then we have 100, so this is our final solution.

49
00:02:03,120 --> 00:02:04,050
Now let's verify.

50
00:02:04,080 --> 00:02:06,150
So the smallest element, we are constructing them.

51
00:02:06,540 --> 00:02:08,610
So the smallest element should be at the top.

52
00:02:08,639 --> 00:02:09,280
That is correct.

53
00:02:09,600 --> 00:02:11,220
Now, Jack, with a complete binary tree.

54
00:02:11,250 --> 00:02:12,600
So this is a complete binary.

55
00:02:12,840 --> 00:02:14,700
Now, a check for the minimum property.

56
00:02:15,090 --> 00:02:17,430
So zero is less than five and one.

57
00:02:17,430 --> 00:02:17,890
Correct.

58
00:02:18,150 --> 00:02:20,040
So five is listed in 14 and 12.

59
00:02:20,160 --> 00:02:20,610
Correct.

60
00:02:20,910 --> 00:02:22,680
14 is listed under the correct.

61
00:02:22,920 --> 00:02:24,260
One is less than nine and six.

62
00:02:24,270 --> 00:02:24,600
Correct.

63
00:02:24,630 --> 00:02:26,510
So this is our correct minimum heap.

64
00:02:27,630 --> 00:02:31,170
Now what we have to do, so we have to remove the minimum element.

65
00:02:31,470 --> 00:02:34,370
So basically I have to remove the element zero.

66
00:02:34,680 --> 00:02:38,070
Again, the formula, the the rules are very simple.

67
00:02:38,250 --> 00:02:39,090
It will slap.

68
00:02:40,450 --> 00:02:44,740
And handler, basically, you have to establish topmost element with the last element, so zero will

69
00:02:44,740 --> 00:02:49,390
come here and it will come here and then you will delete the element zero.

70
00:02:51,060 --> 00:02:55,890
And then what they have to do, so you have to perform down, help you fight operation, so compared

71
00:02:55,890 --> 00:02:57,920
with five and one, so one is a smaller one.

72
00:02:58,170 --> 00:03:03,070
So compared to a step, one 800, 200 will come here and one will come here.

73
00:03:03,780 --> 00:03:05,580
Now, compare that with nine and six.

74
00:03:05,790 --> 00:03:07,080
So six is the smallest.

75
00:03:07,080 --> 00:03:13,350
So strap so 100 will come here and six will come here now after one remove minimum operation.

76
00:03:14,410 --> 00:03:17,350
What is our military what is our minimum help?

77
00:03:17,650 --> 00:03:20,590
So this is one then I have five here.

78
00:03:21,470 --> 00:03:25,770
I have six here, so I have 14 and I have 12.

79
00:03:26,390 --> 00:03:27,350
I have nine.

80
00:03:27,350 --> 00:03:28,670
And then I have 100.

81
00:03:29,030 --> 00:03:32,120
So again, you can see the minimum element when is the minimum element?

82
00:03:32,120 --> 00:03:33,520
And it is at the top.

83
00:03:33,950 --> 00:03:36,440
So, again, we have to apply the remove minimum function.

84
00:03:36,440 --> 00:03:37,900
So we will do the same operation again.

85
00:03:38,480 --> 00:03:41,090
So strap with the last element.

86
00:03:41,120 --> 00:03:44,570
So what will come here and one hundred will come here.

87
00:03:44,870 --> 00:03:49,050
Now you can delete the last element, you can delete the remote minimum element.

88
00:03:49,910 --> 00:03:54,800
So now we have to do we have to perform down here before so compared with five and six.

89
00:03:55,100 --> 00:03:56,300
So five for the smallest.

90
00:03:56,690 --> 00:03:59,370
So five will come here and 100 will come here.

91
00:04:00,110 --> 00:04:03,050
Now among 14 and 12, so 12 is the smallest.

92
00:04:03,110 --> 00:04:04,090
So SUDEP.

93
00:04:04,520 --> 00:04:06,840
So 12 will come here and it will come here.

94
00:04:07,070 --> 00:04:08,630
So finally, what is our three?

95
00:04:10,370 --> 00:04:21,350
So this is our output five, then I have well, so I have six here, then I have 14 here, then I have

96
00:04:21,350 --> 00:04:23,730
100 here and then I have nine here.

97
00:04:24,560 --> 00:04:26,570
So this is our final output.

98
00:04:27,320 --> 00:04:31,930
You can compare your minimum with my help and you can check whether the solution is correct or wrong.

99
00:04:32,240 --> 00:04:33,840
So this is the correct solution.

100
00:04:35,120 --> 00:04:39,870
Now, let us also take one example for the maximum hip so that our concepts become strong.

101
00:04:40,730 --> 00:04:44,750
So now what we want to do, I want to construct maximum hip, hip.

102
00:04:45,350 --> 00:04:52,780
And let's say that elements are, let's say fifteen to twenty nine, let's say zero and 100.

103
00:04:53,480 --> 00:04:55,460
So what is the property for the maximum hip.

104
00:04:55,730 --> 00:05:01,820
So rude value should be greater than the left value and it should be bigger than the right value.

105
00:05:02,480 --> 00:05:03,740
So now let's start.

106
00:05:05,490 --> 00:05:06,750
Now, let's start our discussion.

107
00:05:06,780 --> 00:05:13,350
So first element, ultrafine 15, then the element is two, so two will go in the left hand side now

108
00:05:13,350 --> 00:05:15,360
compared to 15 is then to correct.

109
00:05:15,660 --> 00:05:18,240
Now, 20 or 20 will go in this direction.

110
00:05:18,450 --> 00:05:19,370
Now, what do you have to do?

111
00:05:19,380 --> 00:05:23,360
So you have to perform strapping Grantville come here and 15 will come here.

112
00:05:24,240 --> 00:05:27,030
Now the next element is nine so nine will go ahead.

113
00:05:27,060 --> 00:05:29,400
Now compare to two and nine again.

114
00:05:29,400 --> 00:05:33,990
You have to do stepping so two will come here and nine will compare now nine and 20.

115
00:05:33,990 --> 00:05:34,780
So it is correct.

116
00:05:35,130 --> 00:05:36,480
Now the next element is zero.

117
00:05:36,810 --> 00:05:38,460
So zero will come here.

118
00:05:38,610 --> 00:05:39,390
It is correct.

119
00:05:39,480 --> 00:05:40,890
Now the next element is 100.

120
00:05:41,220 --> 00:05:42,460
200 will come here.

121
00:05:43,020 --> 00:05:44,490
Now compare hundred and fifteen.

122
00:05:44,490 --> 00:05:46,080
So you have to perform stepping.

123
00:05:48,150 --> 00:05:53,260
Now compare hundred and twenty, so again, you have to do sweepings or 20 will come here and hundreds

124
00:05:53,280 --> 00:05:53,820
will come here.

125
00:05:54,150 --> 00:05:55,740
Now, what is my maximum here?

126
00:05:55,830 --> 00:05:56,940
So this is 100.

127
00:05:58,260 --> 00:06:06,180
Then we have nine here we have 20, and then we have two, so here we have zero and then we have 15

128
00:06:06,960 --> 00:06:08,050
now contiguously.

129
00:06:08,130 --> 00:06:10,590
So first of all, this is a complete by nutri.

130
00:06:11,490 --> 00:06:13,350
Now let's check for the Mexi property.

131
00:06:13,710 --> 00:06:15,990
So 100 is greater than nine and 20, correct.

132
00:06:16,140 --> 00:06:17,850
20 is greater than 15, correct.

133
00:06:18,150 --> 00:06:19,460
Nine is according to one zero.

134
00:06:19,470 --> 00:06:19,800
Correct.

135
00:06:19,830 --> 00:06:21,750
So this is our correct mix up.

136
00:06:22,730 --> 00:06:29,590
Now, let us now in this mix up, so in this mix tape, you can see the largest element is under.

137
00:06:29,840 --> 00:06:35,060
So I notice the largest element and the largest element is BESANT at the topmost position, the root

138
00:06:35,060 --> 00:06:35,520
element.

139
00:06:36,050 --> 00:06:40,420
So if you want to call the function, let's get maximum element, what you have to do.

140
00:06:40,430 --> 00:06:44,810
So you just have to retain the element root to the time complexities.

141
00:06:44,810 --> 00:06:45,530
Big of one.

142
00:06:47,600 --> 00:06:53,420
Now, suppose you want to remove Maxim element, so you want to call the function, remove maximum.

143
00:06:54,360 --> 00:06:56,100
So, again, we have to do the same operation.

144
00:06:57,380 --> 00:07:02,420
What they have to do, so I have to compare, I have to separate the element and the last element,

145
00:07:02,420 --> 00:07:09,230
15, so 15 will come here and 100 will come here, and then you can delete the element under the MAKSYM

146
00:07:09,230 --> 00:07:11,320
element and then what you have to do.

147
00:07:11,330 --> 00:07:13,260
So you have to perform down here.

148
00:07:13,290 --> 00:07:22,610
If I compare 15 with the 1920s or 20s, the largest, so swaby 20, so 15 will come here and 20 will

149
00:07:22,610 --> 00:07:23,090
come here.

150
00:07:24,110 --> 00:07:29,650
Now, again, compare 15, so it is correct, we do not have to compare anything.

151
00:07:29,960 --> 00:07:34,250
So finally, what is my binary after Werrimull maximum?

152
00:07:34,260 --> 00:07:41,240
So this is 20, then we have nine, then we have 15, and then we have two, and then we have zero.

153
00:07:41,630 --> 00:07:45,530
So again, you can see the maximum element is always present at the top position.

154
00:07:46,050 --> 00:07:51,560
So mean maximum also remove maximum is log of N down here biffy and.

155
00:07:52,780 --> 00:07:57,360
The insert function is also logoff end up pretty simple.

156
00:07:58,210 --> 00:08:02,420
Now, if you want to perform one more time, if you want to do swapping one more time.

157
00:08:02,600 --> 00:08:08,440
So if you want to remove the MAKSYM element one more time, what you will do again, 20 and zero.

158
00:08:09,190 --> 00:08:11,770
So zero will come here and they will come here.

159
00:08:12,310 --> 00:08:17,800
And then you can remove the last element now jike zero with the nine and 15.

160
00:08:17,800 --> 00:08:22,330
So 15 is the largest, so zero will come here and 15 will come here and we are done.

161
00:08:22,930 --> 00:08:26,380
So finally our maximum.

162
00:08:26,380 --> 00:08:32,840
He is 15, then we have nine here and then we have zero here and then we have 22 here.

163
00:08:33,190 --> 00:08:38,200
So finally, the largest element is present at the top and this is a complete binary and this is also

164
00:08:38,200 --> 00:08:38,860
a maximum.

165
00:08:38,870 --> 00:08:41,020
Hipp So 15 is greater than nine and zero.

166
00:08:41,020 --> 00:08:41,950
Nine is lower than two.

167
00:08:42,429 --> 00:08:44,350
So that's how all these things are working.

168
00:08:45,690 --> 00:08:50,640
So from the next video, we will start implementing our own protocol using hybrid structure.

169
00:08:50,910 --> 00:08:52,720
I will see you in the next one by.

