1 00:00:01,650 --> 00:00:02,400 Hi, everyone. 2 00:00:02,430 --> 00:00:07,950 So starting from this video, we will implement our own triadic you using the Hebrew Dastagir. 3 00:00:08,520 --> 00:00:09,930 So what functions do we need? 4 00:00:10,560 --> 00:00:12,570 So we need one insert function. 5 00:00:14,190 --> 00:00:17,820 The second function that we need is actually the remove function. 6 00:00:18,810 --> 00:00:23,610 For example, if I were implementing meaning prior to Q so I need the function removed minimum. 7 00:00:25,700 --> 00:00:32,060 Now, the terror function, I need to get the minimum function if I'm implementing minimum prior to 8 00:00:32,930 --> 00:00:37,740 the food function that we need is let's say is empty, is my priority empty? 9 00:00:37,760 --> 00:00:38,990 So is empty function. 10 00:00:39,380 --> 00:00:42,380 And the fifth function, let's say we want Getz's. 11 00:00:43,530 --> 00:00:48,090 So how many elements are present in my prior dequeue and as discussed? 12 00:00:49,170 --> 00:00:53,970 We need a complete binary tree, so we will install the computer by Niddrie in an eddy. 13 00:00:54,920 --> 00:00:57,380 So we need an array to store our computer by. 14 00:00:57,800 --> 00:01:01,060 We do not have to construct manually, so there's no point as required. 15 00:01:01,070 --> 00:01:04,580 We will just store our completed by Nutri in our area. 16 00:01:06,050 --> 00:01:08,570 So we will do whatever complete binary tree in an eddy. 17 00:01:08,930 --> 00:01:15,320 And instead of using an array, we will use vectors because vectors are much more powerful than Ediz. 18 00:01:16,310 --> 00:01:19,250 So now let's start implementing our priority. 19 00:01:19,260 --> 00:01:19,820 Giclas. 20 00:01:25,170 --> 00:01:26,640 So glassblower dequeue. 21 00:01:33,450 --> 00:01:39,600 So what do we need so we need an array to store whatever complete binary tree, so let's take a vector 22 00:01:39,600 --> 00:01:40,680 instead of the that. 23 00:01:41,220 --> 00:01:44,610 Just so I want to start I want to create protegé of integers. 24 00:01:45,150 --> 00:01:46,890 And let's say the name is Piku. 25 00:01:48,500 --> 00:01:56,330 So this is private and now let us write some functions inside public, so first of all, the first function 26 00:01:56,330 --> 00:01:58,270 is going to be a constructor. 27 00:01:59,180 --> 00:02:01,530 So let's say it is the default constructor. 28 00:02:01,550 --> 00:02:03,560 So for now, let's leave it empty. 29 00:02:04,340 --> 00:02:05,360 We will discuss it later. 30 00:02:05,360 --> 00:02:08,930 If we have to do something about it, then let us implement. 31 00:02:08,930 --> 00:02:11,030 Our first function is empty function. 32 00:02:14,120 --> 00:02:18,080 So I will be the name of the function is is empty. 33 00:02:23,300 --> 00:02:29,240 So what is functionally done so it will return to Werfel's, whether my priority is empathy or not? 34 00:02:29,630 --> 00:02:35,030 So this is my priority queue BQ, so be good size. 35 00:02:36,330 --> 00:02:41,050 And I will check if it is equal to zero, then return to their downfalls. 36 00:02:41,340 --> 00:02:42,540 So what I'm doing here. 37 00:02:46,740 --> 00:02:53,610 So this size function is actually the function of vectors, so I'm using the same function to get the 38 00:02:53,610 --> 00:02:58,730 size of my vector and then I am checking if it is zero return true otherwise are done false. 39 00:02:59,100 --> 00:03:02,130 So, for example, if my representatives are, what will happen? 40 00:03:02,130 --> 00:03:03,550 Zero equals equals zero. 41 00:03:03,870 --> 00:03:05,090 So this condition is true. 42 00:03:05,100 --> 00:03:06,210 So I'm going to return. 43 00:03:06,210 --> 00:03:06,450 True. 44 00:03:06,900 --> 00:03:10,620 Now let's say if a vector is not empty, let's say it is containing five elements. 45 00:03:11,040 --> 00:03:12,750 So five equals equals zero. 46 00:03:12,780 --> 00:03:14,230 Now this condition is false. 47 00:03:14,280 --> 00:03:15,600 So I'm going to return false. 48 00:03:16,470 --> 00:03:17,570 Now this again. 49 00:03:17,580 --> 00:03:23,700 So this function is in function of this vector class and we have already started vector class in detail. 50 00:03:26,120 --> 00:03:27,980 So is employee function will work fine. 51 00:03:28,940 --> 00:03:35,540 So now let us write one more function gets a function so that it will be integer getz's. 52 00:03:36,930 --> 00:03:42,510 Now, what does good sales function will return, so it will return how many elements are present inside 53 00:03:42,510 --> 00:03:43,260 my Bowdich you? 54 00:03:44,160 --> 00:03:49,320 So basically it will return the size of our priority to. 55 00:03:57,670 --> 00:04:00,910 What we can say, the total number of elements present. 56 00:04:06,940 --> 00:04:13,530 Now, Gert's dysfunction, so what it will done so I can likely use this as a function of vector glass, 57 00:04:13,540 --> 00:04:16,329 so I will return, be good to use simple. 58 00:04:16,540 --> 00:04:20,589 So again, this size function is a function of our vector class. 59 00:04:22,390 --> 00:04:24,430 Now, these two functions are very, very simple. 60 00:04:24,790 --> 00:04:26,770 Now let us implement one more function. 61 00:04:26,890 --> 00:04:27,730 Get the minimum. 62 00:04:30,530 --> 00:04:34,640 So get minimum, but it will return to wavefunction, get minimum. 63 00:04:36,680 --> 00:04:43,430 It will obviously you've done it, Egypt, now I'm implementing minimum priority queue, so what I'm 64 00:04:43,430 --> 00:04:46,910 doing, I am implementing the minimum priority queue. 65 00:04:47,900 --> 00:04:50,340 Now, in the media in particular, let us take an example. 66 00:04:50,870 --> 00:04:52,900 So let's take this example. 67 00:04:52,920 --> 00:04:54,440 So this is a minimum priority. 68 00:04:54,650 --> 00:04:59,480 So this is a minimum heap and how we restore hope in our vector in our area. 69 00:05:00,170 --> 00:05:03,110 So this is one, two, three, and then four. 70 00:05:03,110 --> 00:05:03,780 And then five. 71 00:05:04,130 --> 00:05:05,620 So when is the minimum element? 72 00:05:05,810 --> 00:05:08,630 So when I call the function at the minimum, it should be done one. 73 00:05:08,900 --> 00:05:10,130 So there is one present. 74 00:05:10,160 --> 00:05:17,610 So when we present at the next zero, so one is present at the next room, so I will return the element 75 00:05:17,610 --> 00:05:18,810 to present at the next zero. 76 00:05:19,160 --> 00:05:21,840 So one more time I'm implementing the minimum priority. 77 00:05:21,950 --> 00:05:23,960 That's why I am writing the minimum function. 78 00:05:26,470 --> 00:05:33,760 So what it will return, it will return the element presented 026 now, is this correct? 79 00:05:35,360 --> 00:05:37,490 So is this guy at the minimum function, correct? 80 00:05:37,580 --> 00:05:40,750 No, this is not correct, because what if my priority was empty? 81 00:05:41,240 --> 00:05:44,920 So what if they are a zero element inside my priority queue? 82 00:05:44,960 --> 00:05:50,540 So first, before returning the zero element, you should check whether pretty good and pretty or not. 83 00:05:51,380 --> 00:05:52,370 So how to check. 84 00:05:52,590 --> 00:05:55,370 So I have written this function is empty, so let's copy this. 85 00:05:56,450 --> 00:06:03,050 So I will call this function is empty, so if the function returns true, that means my priority is 86 00:06:03,050 --> 00:06:03,410 empty. 87 00:06:03,440 --> 00:06:05,250 So I can return our default value. 88 00:06:05,270 --> 00:06:08,320 Let's say I am returning zero because we have to return an integer. 89 00:06:08,630 --> 00:06:10,160 So that's why I have to return something. 90 00:06:10,160 --> 00:06:11,370 So let's say I'm returning zero. 91 00:06:11,720 --> 00:06:15,560 So here's zero signifies that my birthday is actually empty. 92 00:06:17,970 --> 00:06:23,310 So we have implemented three functions, three very small, small functions we have implemented good 93 00:06:23,550 --> 00:06:26,590 function is empty function, gateman function. 94 00:06:26,880 --> 00:06:30,680 Now we have to implement insert function and remove minimum function. 95 00:06:31,050 --> 00:06:34,110 So I will discuss these two functions in our next video. 96 00:06:34,350 --> 00:06:39,400 And if you want, you can also implement you can also try to implement these two functions yourself. 97 00:06:39,690 --> 00:06:41,100 That will be a very good practice. 98 00:06:41,500 --> 00:06:42,980 So I will discuss the solution. 99 00:06:42,990 --> 00:06:46,790 I will write the code for the insert and the momentum in the next video. 100 00:06:46,800 --> 00:06:48,020 So I will see you there. 101 00:06:48,070 --> 00:06:48,270 Bye.