• 1 day ago
Transcript
00:00Now let's talk about Heap. If I have to get a minimum, I mean to get a peak. If I
00:06have to get a minimum, I mean to get a peak. So what will happen? I know that my Heap
00:12is already an area list. Area list means index 0, 1, 2, 3, 4, all values are stored.
00:21So, in this way, my array list has all values stored in my array list. So, peak means to remove
00:26minimum element. Minimum element, how do I get out of min heap? Minimum element is always root of my heap.
00:33I already know that if the parent is minimum, then all the tree of my ancestor is the root of
00:40my tree. And root is the top of my heap and my array list is the starting index.
00:47So this will be my minimum. So if I want to peak, which I want to remove? I want to
00:55remove array.get 0. So in my array list, the 0th index is stored in my whole heap minimum value.
01:04So I want to return this value. So I want to make a function public int peak.
01:11In the peak, I have to send the minimum element to the area list. So, I will return the arr
01:17.get . So, I will return the arr.get . So, I will return the arr.get .