1 00:00:01,130 --> 00:00:01,910 Hello, everyone. 2 00:00:01,940 --> 00:00:05,900 So I hope you all give it a try for writing the removed minimum function. 3 00:00:06,200 --> 00:00:09,830 So now let's discuss how we can write, remove minimum function. 4 00:00:10,980 --> 00:00:12,910 So as discussed in the previous video. 5 00:00:12,920 --> 00:00:14,770 So let us take one example first. 6 00:00:15,110 --> 00:00:22,040 So let's say ten hundred and let's say fifty, two hundred and thirty three hundred and let's say I 7 00:00:22,040 --> 00:00:22,960 have it here. 8 00:00:23,240 --> 00:00:24,680 So this is my minimum. 9 00:00:25,490 --> 00:00:26,570 Now what I want to do. 10 00:00:26,930 --> 00:00:30,260 So basically this remove minimum function, what it will do. 11 00:00:30,260 --> 00:00:32,420 So it will remove my top element. 12 00:00:32,689 --> 00:00:33,680 So again so. 13 00:00:35,580 --> 00:00:41,610 This is my vector, Diana Nyad, then two hundred, three hundred and eighty. 14 00:00:42,990 --> 00:00:47,790 So first step is very, very simple, but they have to do so, you have to have these two elements so 15 00:00:48,000 --> 00:00:52,250 they will come here and then will come here and then you will do Bulbeck. 16 00:00:52,590 --> 00:00:53,940 So slap the. 17 00:00:53,970 --> 00:00:57,110 And then and then you will do Bobic. 18 00:00:57,990 --> 00:01:00,110 So first let us write the code for this one. 19 00:01:00,450 --> 00:01:06,660 So if you will do this then you're complete by property has been certified, but the property he bought 20 00:01:06,660 --> 00:01:08,020 the property is not satisfied. 21 00:01:08,460 --> 00:01:11,070 So first let's write this much amount of code. 22 00:01:14,630 --> 00:01:17,330 So the return type of the function is void. 23 00:01:19,470 --> 00:01:20,430 Remove minimum. 24 00:01:23,080 --> 00:01:27,610 So what this function will do, the first step is very, very simple, what we have to do, we have 25 00:01:27,610 --> 00:01:30,220 to accept the first element and the last element. 26 00:01:30,880 --> 00:01:37,630 So I haven't built by I have inbuilt functions swab so you can skip the first element, which is zero. 27 00:01:38,780 --> 00:01:46,700 And the last element is basically to get this index, we can use site function, so Biggart says minus 28 00:01:46,700 --> 00:01:46,910 one. 29 00:01:48,800 --> 00:01:53,900 Now, after sweeping the elements, but we have to do so, we have to be accurate, Bombeck. 30 00:01:56,800 --> 00:02:02,610 So is this thing correct, what we are doing, we are swapping the first element that we have to remove 31 00:02:02,610 --> 00:02:03,900 with the last element. 32 00:02:04,240 --> 00:02:05,990 So is this thing correct? 33 00:02:06,040 --> 00:02:07,290 So it is not correct? 34 00:02:07,310 --> 00:02:07,420 Why? 35 00:02:07,420 --> 00:02:12,640 It is not correct, because first we have to check whether my priority queue is empty or not. 36 00:02:12,670 --> 00:02:14,590 So basically, you have to copy this so-called. 37 00:02:16,710 --> 00:02:20,260 If there are elements in the to go, then only you can remove the minimum element. 38 00:02:20,280 --> 00:02:24,370 But if there are no elements, so if you are prepared to guzik Chilean president, you will return zero. 39 00:02:25,170 --> 00:02:26,820 So this is an arbitrary function. 40 00:02:29,210 --> 00:02:31,100 Similarly, this is empty function. 41 00:02:33,030 --> 00:02:35,610 So we'll call, so you will call is embassy function. 42 00:02:36,630 --> 00:02:41,770 And if the key is not if the Braddick is not empty, then only you will remove that element. 43 00:02:42,360 --> 00:02:44,590 OK, so let's change the function. 44 00:02:44,610 --> 00:02:50,370 So what we will do, we will also return that element, the element which we are, the element which 45 00:02:50,370 --> 00:02:51,660 we are trying to delete. 46 00:02:51,690 --> 00:02:52,970 We will also return that element. 47 00:02:52,980 --> 00:02:56,030 So before deleting that element stored that element. 48 00:02:56,550 --> 00:02:57,870 So because of zero. 49 00:02:59,640 --> 00:03:05,310 So I'm storing that element in as a variable, then I am deleting that element and then what I will 50 00:03:05,310 --> 00:03:06,970 do, so I will return that element. 51 00:03:08,190 --> 00:03:09,540 So we are doing two things here. 52 00:03:09,960 --> 00:03:11,550 I'm storing that element. 53 00:03:11,550 --> 00:03:14,990 I will return the minimum element and I will also destroy the minimum element. 54 00:03:15,000 --> 00:03:17,280 I will also remove the minimum element from my priority. 55 00:03:17,350 --> 00:03:20,790 You now at this point and what is happening. 56 00:03:21,060 --> 00:03:28,890 So my CBT property has been satisfied, but my mini property, so the keyboarder property is not satisfied. 57 00:03:29,340 --> 00:03:32,370 So what we have to do, we have to do down here if I. 58 00:03:33,720 --> 00:03:37,200 So we have done many examples how we will do down here if I. 59 00:03:39,580 --> 00:03:41,650 So let's understand one more time. 60 00:03:43,020 --> 00:03:49,140 So for doing down here, if the logic is going to be very, very simple, we need three variables sorry 61 00:03:49,170 --> 00:03:49,890 for the variables. 62 00:03:50,430 --> 00:03:57,180 We index left index, right index and one more variable minimum index. 63 00:03:59,570 --> 00:04:04,860 So initially, what is so these are indexes zero, one, two, three and four. 64 00:04:04,880 --> 00:04:06,290 So this does not exist. 65 00:04:07,250 --> 00:04:09,430 So beyond indexes, initially zero this one. 66 00:04:09,920 --> 00:04:13,250 So index is zero left this one right at two. 67 00:04:13,610 --> 00:04:17,940 So left index is one right next to you can use the formula the way plus one. 68 00:04:17,959 --> 00:04:20,980 And here you can use the formula the way Plaistow. 69 00:04:21,500 --> 00:04:22,700 So this is one actually. 70 00:04:23,860 --> 00:04:30,430 And initially, let's say my parent is the minimum element, so minor indexes, zero, then really have 71 00:04:30,430 --> 00:04:34,040 to do so, compare the parent element with the child. 72 00:04:34,060 --> 00:04:35,790 So compare it with hundred. 73 00:04:36,010 --> 00:04:38,020 So it is less than under do nothing. 74 00:04:39,040 --> 00:04:46,780 Now, compare your parent index with the right index, so compare it with 50, so 50 is less. 75 00:04:46,960 --> 00:04:48,780 So what you will do, you will do the slapping part. 76 00:04:49,000 --> 00:04:52,180 So it will come here and 50 will come here. 77 00:04:53,020 --> 00:04:58,870 So what you have to do so you will update your minimum index because index is containing the index of 78 00:04:58,870 --> 00:05:02,270 that element, which is the smallest, so smallest index is now two. 79 00:05:02,650 --> 00:05:06,190 So we will update you index and then we will do we will do the shopping. 80 00:05:07,070 --> 00:05:15,850 So we will set the value value present at the parent index and the value present at the minimum index. 81 00:05:17,070 --> 00:05:22,380 So the value presented parent index was 80, the value presented index was 50. 82 00:05:23,220 --> 00:05:28,380 Now we have said so after this, the next step, but we have to do so. 83 00:05:28,380 --> 00:05:29,510 It is now presented. 84 00:05:29,550 --> 00:05:31,710 So it will compare with its left and right child. 85 00:05:31,950 --> 00:05:36,810 So basically, what is the index of its index of it is actually two and two is the minimum index. 86 00:05:37,110 --> 00:05:38,730 So what will happen to will come here. 87 00:05:39,540 --> 00:05:41,820 So too is my new parent index. 88 00:05:42,720 --> 00:05:43,230 Simple. 89 00:05:43,500 --> 00:05:48,990 So I will initialize my minimum index with I have my index with two. 90 00:05:49,830 --> 00:05:52,650 Now what you have to do to find out is left and right jel index. 91 00:05:52,650 --> 00:05:55,100 So left and right index is actually five and six. 92 00:05:55,740 --> 00:06:03,090 So what you will do, you will compare two with five the value index to the developers index five. 93 00:06:03,120 --> 00:06:05,280 But Index five is actually out of range. 94 00:06:05,550 --> 00:06:06,840 So you will not compare. 95 00:06:07,110 --> 00:06:13,350 And similarly, if the index is out of range, then automatically the right next is also out of range. 96 00:06:14,190 --> 00:06:15,920 So similarly, you will not compare. 97 00:06:17,160 --> 00:06:18,060 You will not compare. 98 00:06:18,060 --> 00:06:25,440 And then what you will do so again, you will write the same code srep the value that the parent index 99 00:06:25,800 --> 00:06:28,170 with the value present at the minimum index. 100 00:06:28,680 --> 00:06:31,090 But here both the index is the same. 101 00:06:31,950 --> 00:06:34,210 So this is also true and this is also true. 102 00:06:35,700 --> 00:06:37,430 So this is my shopping criteria. 103 00:06:39,000 --> 00:06:40,060 This is my stopping. 104 00:06:40,490 --> 00:06:46,980 So if the parent index become equal to the minimum index, that means the parent. 105 00:06:47,610 --> 00:06:51,060 That means the node has been positioned at the right position. 106 00:06:51,240 --> 00:06:52,200 So I will stop. 107 00:06:52,380 --> 00:06:53,790 So at this point, I can stop. 108 00:06:55,110 --> 00:06:55,650 Simple. 109 00:06:56,670 --> 00:06:57,690 So now let's write the. 110 00:07:02,120 --> 00:07:06,620 So far down here, Biffy, first of all, what you have to do, so let us find out the spirit index. 111 00:07:07,520 --> 00:07:10,190 So Birand Index, so what is index? 112 00:07:10,190 --> 00:07:11,510 It is zero simple. 113 00:07:13,470 --> 00:07:16,080 Now, while so suppose you do not know the. 114 00:07:17,860 --> 00:07:22,000 Suppose you don't know the stopping conditions, so let's make it while true. 115 00:07:22,940 --> 00:07:27,540 So this look learned time, and then we will figure out what will have a stopping idea. 116 00:07:28,010 --> 00:07:31,480 So what we have to do, we have to find out our left index. 117 00:07:32,170 --> 00:07:33,740 That will be two times of. 118 00:07:34,730 --> 00:07:38,240 Brent, so let's make it small, because I will do a mistake again. 119 00:07:39,970 --> 00:07:46,300 So this is through times of pain and index plus one, what is my right index? 120 00:07:46,480 --> 00:07:51,760 So right index is two times of being index plus two. 121 00:07:53,300 --> 00:07:56,720 Simple, then what they have to do, you have to take one more variable. 122 00:07:57,650 --> 00:08:04,450 Minimum index, so this minimum index is actually, let's say initially, this is equal to the index, 123 00:08:04,460 --> 00:08:04,970 you can see. 124 00:08:05,960 --> 00:08:08,670 Initially, the minimum indexes, actually the index. 125 00:08:08,690 --> 00:08:13,070 So if this was zero, then initially my band index was also zero. 126 00:08:13,100 --> 00:08:18,410 Similarly, if the band index was too slow, initially my index was also to. 127 00:08:20,450 --> 00:08:23,090 And then what do you have to do so you have to do the comparison part. 128 00:08:25,400 --> 00:08:28,650 You have to find out so you can see what I'm doing. 129 00:08:28,670 --> 00:08:33,440 I have to do this comparison, but I will compare these two values and then I will compare these two 130 00:08:33,440 --> 00:08:33,919 values. 131 00:08:35,020 --> 00:08:36,090 So let's do that. 132 00:08:40,159 --> 00:08:47,720 So if the value presented left index is less than the value presented the parent, less than the value 133 00:08:47,720 --> 00:08:51,020 presented the minimum index, then what they will do? 134 00:08:52,240 --> 00:08:55,630 You will update your main index will be the left index. 135 00:08:57,180 --> 00:09:00,780 And similarly, if the value. 136 00:09:02,200 --> 00:09:10,390 Present presented right next is less than the value president dead, the minimum index, then what he 137 00:09:10,390 --> 00:09:10,720 will do? 138 00:09:11,970 --> 00:09:16,170 You will update your Menom index, but with the right index symbol. 139 00:09:17,280 --> 00:09:23,160 Now, after doing all this, what do you have to do so after reading the index, what we have to do 140 00:09:23,160 --> 00:09:24,930 so we have to do this step in part. 141 00:09:25,590 --> 00:09:30,090 So I'm sweeping the value plays in that index with the value that the minimum index. 142 00:09:31,950 --> 00:09:33,360 So it's representable function. 143 00:09:34,290 --> 00:09:41,540 So I have to scrap the value present at the index with the value present at the minimum index. 144 00:09:42,210 --> 00:09:42,720 Simple. 145 00:09:43,170 --> 00:09:45,050 And then you can see what I'm doing. 146 00:09:45,480 --> 00:09:47,720 So after doing this I am updating my. 147 00:09:48,090 --> 00:09:49,980 So this is for the next iteration. 148 00:09:52,610 --> 00:09:54,030 This is for the next iteration. 149 00:09:54,050 --> 00:09:59,000 So this was my first iteration, so for next iteration, what I have to do, so I have to update the 150 00:09:59,000 --> 00:10:02,570 value of my parents next to be the minimum child index. 151 00:10:03,350 --> 00:10:08,480 So for next iteration, my parent index, it is nothing but the minimum child index. 152 00:10:08,810 --> 00:10:10,790 So the minimum index symbol. 153 00:10:11,390 --> 00:10:14,810 Now, let's take one more example to understand what is going on. 154 00:10:20,840 --> 00:10:28,810 So let's say I have this binary tree, this minimum hip, so 10 hundred, let's said this is equal to 155 00:10:28,850 --> 00:10:32,480 this is 200, this is four hundred. 156 00:10:33,080 --> 00:10:34,940 And let's say this is 18. 157 00:10:36,900 --> 00:10:38,370 And let's say this is 15. 158 00:10:40,610 --> 00:10:46,190 So this is a valid manip now I want to delete the minimum element, so I will call the remote minimum 159 00:10:46,190 --> 00:10:47,840 function and I want to remove them. 160 00:10:48,380 --> 00:10:49,660 So this is index zero. 161 00:10:49,700 --> 00:10:50,500 This is index one. 162 00:10:50,510 --> 00:10:52,640 This is index to index three. 163 00:10:53,120 --> 00:10:55,450 Index for index five and index. 164 00:10:56,300 --> 00:10:58,310 So what I will do, I will set these two values. 165 00:10:59,150 --> 00:11:03,560 So 15 is going to come here then is going to come here and then I will pop. 166 00:11:04,760 --> 00:11:06,610 OK, so I was also starting. 167 00:11:06,620 --> 00:11:07,760 So before swiping. 168 00:11:08,300 --> 00:11:13,610 Before stepping, I was starting my own second variable answer and then I'm returning my answer, so 169 00:11:13,610 --> 00:11:14,210 I will return. 170 00:11:14,210 --> 00:11:19,610 Ben Nonissues So after 15, what is my band. 171 00:11:19,610 --> 00:11:21,090 Index of parental index is zero. 172 00:11:21,110 --> 00:11:22,550 So I am writing here. 173 00:11:22,910 --> 00:11:24,340 So this is my parent index. 174 00:11:24,350 --> 00:11:26,080 This is going to be left index. 175 00:11:26,090 --> 00:11:29,210 This is the index and this is the index. 176 00:11:30,870 --> 00:11:32,190 So index zero. 177 00:11:33,300 --> 00:11:41,600 Left index is one, index is two, and initially my minimum index is actually parent of parent index, 178 00:11:41,600 --> 00:11:46,030 so zero then compare the value presented left index with index. 179 00:11:46,030 --> 00:11:50,270 So index is hundred to compare one hundred with fifteen. 180 00:11:50,760 --> 00:11:51,680 Nothing will happen. 181 00:11:52,050 --> 00:11:55,110 Then compare the RAYCHELLE index with index. 182 00:11:55,110 --> 00:11:59,010 So right index with index of twelve is less than 15. 183 00:11:59,410 --> 00:12:05,220 So what I going to do, I will update my index values or index value is now containing two. 184 00:12:06,390 --> 00:12:12,620 And then in the next lane, we are stepping, so I will step to I will come here and 15 will come here. 185 00:12:13,170 --> 00:12:15,930 Then in the next lane I am updating my spirit index. 186 00:12:16,260 --> 00:12:17,030 So what will happen? 187 00:12:17,040 --> 00:12:18,050 These two will come here. 188 00:12:18,840 --> 00:12:23,910 You can see for index for 2015, new indexes do so. 189 00:12:24,030 --> 00:12:26,110 Now, again, the next iteration will start. 190 00:12:26,370 --> 00:12:28,230 So find out the left index. 191 00:12:28,230 --> 00:12:29,820 So left index is actually five. 192 00:12:30,080 --> 00:12:32,370 Find out the index, which is six. 193 00:12:32,670 --> 00:12:35,700 And initially your index is actually parent index. 194 00:12:35,700 --> 00:12:43,580 Apparently indexes do now again compare so left index or the index or left index is eighteen, so eighteen 195 00:12:43,590 --> 00:12:46,080 is good and fifteen do nothing then. 196 00:12:46,080 --> 00:12:48,030 Right index an index. 197 00:12:48,420 --> 00:12:52,110 Raychelle index is six but six is not a valid index. 198 00:12:52,710 --> 00:12:54,270 So we have to add a Jacare. 199 00:12:55,170 --> 00:12:58,530 So index is not a index so you will not compare. 200 00:12:59,070 --> 00:13:05,100 OK, we will not compare and then there is no need to set because in this web the parent index, in 201 00:13:05,100 --> 00:13:08,550 the minimum index the voters seem so two and two, they both are same. 202 00:13:09,090 --> 00:13:11,100 So what we have to do so we have to do two things. 203 00:13:11,220 --> 00:13:13,290 First thing, we have to add checks. 204 00:13:14,990 --> 00:13:20,930 Rejects, for example, you are comparing the left index or left index should exist, you are comparing 205 00:13:20,930 --> 00:13:23,570 the right index to right Jellinek should exist. 206 00:13:23,780 --> 00:13:26,070 And second, this is messed up in great detail. 207 00:13:26,090 --> 00:13:30,350 You can see 15 is now 15 is present at its correct position. 208 00:13:31,730 --> 00:13:38,300 So you can see the index and the minimum index, the articles when they are equal, that means my bindery, 209 00:13:38,300 --> 00:13:40,970 my heap or their property has been satisfied. 210 00:13:42,110 --> 00:13:43,250 So let's do this. 211 00:13:44,700 --> 00:13:46,610 So first of all, we have two checks. 212 00:13:47,030 --> 00:13:47,990 We have to add checks. 213 00:13:47,990 --> 00:13:50,410 So left index should be a valid index. 214 00:13:50,690 --> 00:13:53,210 So that means it should be listin be good size. 215 00:13:55,970 --> 00:14:03,410 And similarly, the Rachell index should be a valid index index should be listing the accurate size. 216 00:14:09,350 --> 00:14:16,010 And before stepping check, what we will do, we will add a check, so if the appendix is actually. 217 00:14:17,490 --> 00:14:22,590 So if the Menom index is actually the index, so that means. 218 00:14:23,880 --> 00:14:24,700 My hip. 219 00:14:24,720 --> 00:14:28,410 That means my hip or the property has been set aside, so you can do break. 220 00:14:29,760 --> 00:14:32,590 You can go back and this value will be over. 221 00:14:33,180 --> 00:14:34,710 We can write this big statement. 222 00:14:36,110 --> 00:14:37,890 So I think our culture work fine. 223 00:14:37,910 --> 00:14:39,970 So now let us try to test our culture. 224 00:14:42,560 --> 00:14:45,650 So let us first create an object of Depay ridiculous. 225 00:14:48,980 --> 00:14:55,240 Many of the objectives be and let us insert so we have to test insert function, so let us insert some 226 00:14:55,240 --> 00:14:55,690 elements. 227 00:15:10,630 --> 00:15:20,080 Today, elements are 100 percent under 10 to 15, 34 to 17 to 21 and led to 67. 228 00:15:22,700 --> 00:15:30,290 So I am inserting these elements and now let us bring something so suppose I want to print size so that 229 00:15:30,290 --> 00:15:34,640 if the object is B and the function, then the function was Getz's. 230 00:15:39,400 --> 00:15:42,310 And now let us also try to find out the minimum element. 231 00:15:44,190 --> 00:15:49,200 So we don't get the minimum, so it will be done me. 232 00:15:50,360 --> 00:15:56,150 It will be done with the minimum element present in the priority queue and now let's also bring. 233 00:15:58,370 --> 00:16:00,800 Let us also test our removed minimum function. 234 00:16:02,110 --> 00:16:06,790 So while my verdict is not empty. 235 00:16:08,800 --> 00:16:10,840 Well, I bet you guys are pretty what we have to do. 236 00:16:12,790 --> 00:16:19,570 Give me the remove give me the minimum element each time, so I will call remove medium function. 237 00:16:22,850 --> 00:16:24,590 And it will give me the minimum element. 238 00:16:35,950 --> 00:16:37,090 So what is happening here? 239 00:16:38,410 --> 00:16:43,900 So these are the number of elements, so I am inserting hundred, so first hundred welcome. 240 00:16:45,010 --> 00:16:50,760 Then I'm inserting tents or tent will go in the left direction, so Dennis, less than hundreds of zapping 241 00:16:50,770 --> 00:16:53,920 will take place and it will come here and then will come here. 242 00:16:54,190 --> 00:16:55,360 Then I'm adding 15. 243 00:16:55,370 --> 00:16:56,080 So 15. 244 00:16:56,680 --> 00:16:57,850 So 15 is correct. 245 00:16:57,850 --> 00:16:58,570 Now four. 246 00:16:58,870 --> 00:17:00,220 So four will come here again. 247 00:17:00,220 --> 00:17:01,080 You have to do stepping. 248 00:17:01,420 --> 00:17:06,430 So this will become four and 100 will come here, then compare four and ten. 249 00:17:06,760 --> 00:17:09,569 So then we'll come here and four will come here. 250 00:17:10,119 --> 00:17:12,849 Next element is 17 to 17. 251 00:17:13,089 --> 00:17:14,410 Yes, 17 is correct. 252 00:17:14,410 --> 00:17:17,569 17 is basically lower than 10 now 21. 253 00:17:17,579 --> 00:17:20,609 So 21 or yes, 21 is greater than 15. 254 00:17:20,619 --> 00:17:21,040 Correct. 255 00:17:21,550 --> 00:17:22,390 67. 256 00:17:22,810 --> 00:17:24,730 So 67 is good and 15. 257 00:17:24,730 --> 00:17:25,099 Correct. 258 00:17:25,390 --> 00:17:27,099 So what is my hip. 259 00:17:27,130 --> 00:17:29,500 So this is for then. 260 00:17:29,500 --> 00:17:35,790 This is 10, then this is 15, then this is 100, then this is 17. 261 00:17:36,250 --> 00:17:38,830 So this is done doing and this is 67. 262 00:17:39,070 --> 00:17:40,780 So this is my minimum hip. 263 00:17:42,630 --> 00:17:48,180 This is my minimum hip and now what I'm printing, so first time printing gets out. 264 00:17:48,210 --> 00:17:49,450 So how many elements are there? 265 00:17:49,470 --> 00:17:52,860 So seven elements are so output should be seven then. 266 00:17:52,860 --> 00:17:54,390 I'm calling it the minimum function. 267 00:17:54,660 --> 00:17:56,310 So four is the minimum element. 268 00:17:56,310 --> 00:18:01,200 So I will get four then I'm calling while my priority queue is not empty. 269 00:18:01,200 --> 00:18:03,370 I am removing minimum element each time. 270 00:18:03,570 --> 00:18:04,380 So what happened? 271 00:18:04,380 --> 00:18:06,120 So fast food. 272 00:18:06,870 --> 00:18:10,140 Then next time 10 will be printed because it will become the minimum element. 273 00:18:10,500 --> 00:18:17,030 Then 15 is the minimum element, then 17 is implemented, then 21, then 67 and then 100. 274 00:18:17,850 --> 00:18:21,930 So basically these two things will be my output seven, then four. 275 00:18:21,930 --> 00:18:23,430 And then and so I did a method. 276 00:18:24,030 --> 00:18:25,890 So let's try to test our gold. 277 00:18:37,210 --> 00:18:38,200 So what is the added? 278 00:18:53,400 --> 00:18:54,060 OK, so. 279 00:18:55,090 --> 00:19:00,610 See, this record is actually corresponding to this one by loop, so I have to add one more record here. 280 00:19:12,970 --> 00:19:16,800 So you can see so this is so let me run my program again. 281 00:19:28,790 --> 00:19:31,360 So you can see our court is working fine. 282 00:19:32,210 --> 00:19:36,580 So first I am bending my size, so I inserted seven elements that slide. 283 00:19:36,590 --> 00:19:38,200 The output is coming out to be seven. 284 00:19:38,720 --> 00:19:40,490 Then I am printing the minimum elements. 285 00:19:40,610 --> 00:19:42,550 Among these, the minimum element is four. 286 00:19:42,830 --> 00:19:45,670 So let's say four is the output and then what I'm doing. 287 00:19:45,890 --> 00:19:52,800 So while my priority is not to remove one element each time and you can see so in the remove minimum 288 00:19:52,850 --> 00:19:58,940 function, I'm storing that minimum number, I am storing that number, then delete that minimum number 289 00:19:58,940 --> 00:20:05,010 and then I'm returning that minimum number so you can see the output is in mind. 290 00:20:05,060 --> 00:20:10,160 So this is four, then 10, 15, 17, 21, 61 and 100. 291 00:20:10,400 --> 00:20:13,100 So our output is coming out in a sorted of. 292 00:20:14,260 --> 00:20:18,430 Now, if you remember, we have covered starting algorithm's. 293 00:20:19,810 --> 00:20:25,540 So you can see the output is coming out in assorted manner and this thing is actually called Ahepe. 294 00:20:26,440 --> 00:20:29,480 So we have discussed many sorting algorithms like Selection Bubble. 295 00:20:29,770 --> 00:20:32,130 So this is new sorting algorithm, heaps hard. 296 00:20:35,250 --> 00:20:41,370 Now, let us discuss the time complexity for Cheapside, so suppose you are given an elements. 297 00:20:44,170 --> 00:20:49,330 So you are provided with the elements and what do you have to do so you have to sort those end elements? 298 00:20:55,270 --> 00:20:56,650 So we are talking about. 299 00:20:57,610 --> 00:20:58,950 So in salt. 300 00:21:00,470 --> 00:21:03,140 I want to discuss the time in the space complexity. 301 00:21:04,560 --> 00:21:11,130 So he is basically you are given an elements and you have to sort those elements, so the first step 302 00:21:11,130 --> 00:21:12,510 is very simple, what they have to do. 303 00:21:12,720 --> 00:21:16,320 You have to insert those elements into our minimum hip. 304 00:21:17,070 --> 00:21:18,780 So we have created a minimum hip. 305 00:21:18,780 --> 00:21:22,460 If you remember, we have written the code for the medium vertical. 306 00:21:22,920 --> 00:21:26,550 So what I'm doing, I'm inserting those elements into our protocol. 307 00:21:26,790 --> 00:21:31,590 So if you remember the insertion function, so the time complexities log often. 308 00:21:31,620 --> 00:21:37,650 We have discussed it many times and similarly, the deletion function, it is also log often. 309 00:21:38,130 --> 00:21:39,880 So we have discussed it many, many times. 310 00:21:40,770 --> 00:21:46,480 So first of all, we have to insert any elements and for inserting one element of time, complexity, 311 00:21:46,500 --> 00:21:50,400 slogan software, inserting an element of time, complexity will be a login. 312 00:21:51,550 --> 00:21:57,400 Now, after inserting the elements, but we have to do so, we have to remove any elements and for removing 313 00:21:57,400 --> 00:22:01,810 one element time complexities log off and you can see what we are doing. 314 00:22:02,360 --> 00:22:04,300 We have to remove any elements. 315 00:22:04,570 --> 00:22:11,030 And for removing one element, the time complexity is long, often so over time complexity. 316 00:22:11,050 --> 00:22:15,480 So we want to remove an element for removing one element from complexities. 317 00:22:15,490 --> 00:22:15,730 Log. 318 00:22:15,850 --> 00:22:22,450 And so this is the total time complexity and Logan to San Lorenzo, this and Logan to time complexity 319 00:22:22,450 --> 00:22:24,220 for Heap's Art is and Logan. 320 00:22:25,930 --> 00:22:30,980 Now, let us discuss this complexity, so can we say space complexity is big often? 321 00:22:31,000 --> 00:22:34,510 No, we cannot say because you can see what we are doing. 322 00:22:34,510 --> 00:22:36,150 We are creating a vector. 323 00:22:36,820 --> 00:22:40,010 So my complete binary is actually stored in a vector. 324 00:22:40,420 --> 00:22:47,590 So if I have an element where the size of my vector, so first I'm inserting those elements into my 325 00:22:47,590 --> 00:22:50,930 vector so the space complexity will become big often. 326 00:22:51,250 --> 00:22:53,710 So this is basically due to vector. 327 00:22:56,720 --> 00:23:03,500 Now, this was he thought so because we created a minimum priority, so that's why our element was present 328 00:23:03,530 --> 00:23:04,580 in increasing order. 329 00:23:05,150 --> 00:23:08,090 So if we will implement the maximum player dequeue. 330 00:23:09,090 --> 00:23:15,900 Then our elements will come out in descending order so we can start in ascending order and we can also 331 00:23:15,900 --> 00:23:17,640 start in descending order, simple. 332 00:23:18,000 --> 00:23:21,270 And this is the final time and space complexities of time. 333 00:23:21,420 --> 00:23:26,460 And Logan, he saw this taking a long time and the space is actually big and. 334 00:23:27,610 --> 00:23:34,250 Now, in the next few days, we will discuss how we can optimize on space complexity, so I will see 335 00:23:34,250 --> 00:23:35,770 you in the next one by.