Connected Components | C++ Placement Course | Lecture 34.9

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

The name of this question in hackerrank is JOURNEY TO THE MOON.

ayushbisht
Автор

The vis[i] = true in the for loop within get_comp is redundant I feel. It will be anyways set to true in the recursive call.

Subhankar
Автор

Graphs series release pls. And question or. Lecture bahut ache hai.

yashvarshney
Автор

The code for finding the no. of Connected components can be written simply as follows-
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>adj;
vector<bool> visited;
int c;
void dfs(int n)
{
visited[n]=true;
for(auto i:adj[n])
{
if(visited[i]==false)
{
dfs(i);
} } }

int main()
{
c =0;
int ver, edg;
cin>>ver>>edg;
adj= vector<vector<int>>(ver);
visited=vector<bool> (ver, false);
for(int i=0;i<edg;i++)
{
int m, n;
cin>>m>>n;
adj[m].push_back(n);
adj[n].push_back(m);
}
for(int i=0;i<ver;i++)
{
if(visited[i]==false)
{
c++;
dfs(i);
}
}
cout<<"No. of connected components are "<<c<<endl;
return 0;
}

sakshamgupta
Автор

Sir few lecture are not arranged in perfect order check starting 20 lecture title and edit playlist serial no.

deepak
Автор

Sir javascript k liye course kab tk aye ga

suyashacharya
Автор

👍👍👍.
Bhaiya agla course kali Linux pe banana🙏🙏.

kirtansuthar
Автор

Plz provide the quesion links on the description, as then we would first try it and see if its right and then see your approach.

akasksingh
Автор

Why should we take long long? Why not long or int?

rahul_ji
Автор

And drive per graph ke question nahi hai

yashvarshney
Автор

Hi . Can this course be done by people working in MNC from 2-3 years, but want to get selected in Product base company which gives higher packages? Will there be guidance available for them too after completing 2 phases? Please reply

randomclickz
Автор

Bhai kya ye course class 12 vale bhi dekh sakte hai

ritumishra
Автор

Actually bhaiya I'm get late to grasp the rhythm... Yesterday I got to know about your c++ series... What should I do ? Please guide me 🥺🙏....

h_a_r_s_h
Автор

Should have included test cases and constraints

sirajkhan
Автор

Sir java gui ke uper playlist kab bano ge

sumiharsola
Автор

Graph ka 10 11 course private kyun hai bhaiyaa....

praj
Автор

Bhaiya kab tak web dev series khatam hoga??

falcon_sgamez
Автор

3:43 what's difference between global and local vector?

rahul_ji
Автор

i think there is mistake in ques 2 and it would be : -

for(int i=0;i<components.size();i++)
{
for(int j=0;j<components.size();j++)
{
if(i!=j)
ans = ans + components[i]*components[j];
}
}

hritikrastogi
Автор

Wo issliye tumne global kita kyunki geeks for geeks pe bhi global kiya hua tha😂😂

Adityasharma-oezp
welcome to shbcf.ru