Merge two binary Max heaps | Is Binary Tree Heap | BST to max heap

preview_player
Показать описание
Heap Tree| Priority Queue | Data Structure and Algorithm | 180daysofcode #dsa #heap #india

00:00 Introduction
00:19 Problem 1 - Merge two binary Max heap
4:41 Calculating Time Complexity
5:32 Code Part - Merge two binary Max heap
10:15 Problem 2 - Is Binary Tree Heap ?
20:09 Calculating Time Complexity
21:26 Code Part - Is Binary Tree Heap ?
34:56 Problem 3 - BST to Max Heap
42:16 Time Complexity
42:34 Another Example for Problem 2
47:57 Code Part - BST to Max Heap
54:24 Last Note

Day 189/180, #180daysofcode #180 hard

We are doing 180 days challenge and going to complete the whole course within the duration with quality content on Youtube. I am on the mission to create a tech revolution in our country and in upcoming future we want to create a tech which will create many jobs in India.

Video will come on Mon-Fri at 6am in the morning

DSA Course for free
C++ Free Course
Rohit Negi DSA Course C++
Coder Army DSA Course c++
Function in C++
Pointers in C++.
Strings
Vector
Introduction to Recursion

Рекомендации по теме
Комментарии
Автор

best dsa teacher on youtube, hatsoff

divyanshrawat
Автор

Completed 2/3 question. Solved 2nd question by taking hint.

asad_iliyas
Автор

bhaiya aap hmare liye bhot hardwork kr rhe ho thankyou so much
🙏🙂

aakankshasharma
Автор

Thanks bhaiya for wonderful lecture question no 2 i solve by different approach it takes also 0(N) T.C
bool isHeap(struct Node* tree) {
// code here
int p=0;
queue<Node*>q;
q.push(tree);
while(!q.empty())
{
Node *temp=q.front();
q.pop();
if(temp->left)
{
if(temp->data >=temp->left->data)
{
q.push(temp->left);
}
if(p==1 || temp->left->data >temp->data)
{
return false;
}
}
else
{
p=1;
}
if(temp->right)
{
if(temp->data >=temp->right->data)
{
q.push(temp->right);
}
if(p==1 || temp->data <temp->right->data)
{
return false;
}
}
else
{
p=1;
}

}
return true;
}

AadityaChy-skog
Автор

Good morning bhaiya,

New video on Coder army = happiness

animani
Автор

Jai shree Ram ❤️ bhaiya you deserve much more than this I feel sorry when you do such 🙏 hardwork and don't get the desired retention of student

heetpatel
Автор

problem no 1:
Galti se two pointer approach laga diya 😅😅😅

class Solution{
public:
vector<int> mergeHeaps(vector<int> &a, vector<int> &b, int n, int m) {
// your code here
vector<int> ans;
int ptr1 = 0;
int ptr2 = 0;
while(ptr1 < a.size() && ptr2 < b.size()) {
if(a[ptr1] > b[ptr2]) {
ans.push_back(a[ptr1++]);
} else {
ans.push_back(b[ptr2++]);
}
}

while(ptr1 < a.size()) {
ans.push_back(a[ptr1++]);
}

while(ptr2 < b.size()) {
ans.push_back(b[ptr2++]);
}
return ans;
}
};

Aniruddha_Mukherjee
Автор

Problem 1 code:
Easy and Simple to understand 😃

class Solution{
public:
vector<int> mergeHeaps(vector<int> &a, vector<int> &b, int n, int m) {
vector<int> ans;
priority_queue<int> pq;

// Push all elements from the first heap (a) into the priority queue
for(int i = 0; i < n; i++){
pq.push(a[i]);
}

// Push all elements from the second heap (b) into the priority queue
for(int j = 0; j < m; j++){
pq.push(b[j]);
}

// Pop all elements from the priority queue into ans
while(!pq.empty()){
ans.push_back(pq.top());
pq.pop();
}

return ans;
}

};

memesofengineer
Автор

Bhaiya btech cs nhi mil rahi hai btech electronics ya mechanical mil rahi hai ~ Btech mechanical / electronic karu ya BCA CS karu ??
Pls Guide me Bhaiya

learnwithinspire
Автор

I have been watching your DSA videos for more than 7 months, Even I also bought a paid DSA course but it does not match the quality you are providing. So, I have decided to stick with your course only.

fachoyt