BHAIYA 36TH EDGE KE LIYE HUM ESE KYO KAR RHE HAI _>
g.addedge(36,36);
???
BHAIYA 36TH EDGE KE LIYE HUM ESE KYO KAR RHE HAI _>
g.addedge(36,36);
???
hello @CODER_JATIN
us line se uppar waala loop dekho , wo bus 35 tak hi chalega.
matlab ki 35 tak jitne vertex hai, unse nikalne waale edge to hum add kar lenege graph me but 36 se niklane wale nahi kar payenge.
isilye loop se bahar aane ke baad ye edge add kiya humne jo 36 se nikal ke 36 pe hi aata hai (isko self loop bolte hai).
matlab ki tum 36 pe ho to 36 pe hi rahoge agar ye edge use kiya to
lekin bhaiya 36 se nikalne wale edge ki hamey jarurat hi nhi hai, fir kya fayda?
ha isme sawal me nahi hai , but kisi aur me ho sakti hai
maan lo tum x step me 36 se pe pahuch jaate ho .
ab agar sawal ye ho ki x + y step me tum kaha hoge? answer hai 36 pe hi.
kaise ? tum 36 pe pahuchne ke baad baar baar self edge use karoge y times.
acha acha thik hai smjh gya !!,
lekin bhaiya is sawal m agr mai ye cheez nhi daalta g.addedge(36,36) ,
to ans galat kyo aa rha fir?
apna code bhejo mujhe mai check karta hun. . . . . . .
bro bhaiya , map use kar rahe hai graph banane ke liye isiliye unke code me ye line likhna jaruri hai, kyunki uske bina map ko pata nahi chalega ki 36 naam ka koi vertex hai bhji ya nahi.
agar tum array ya vector use karoge graph banane ke lie tab wo condition jaruri nahi hai
bhaiya smjha ni mai ??
or ek baar mera ye code bhi dekhna
kya dikkat hai ->
or bhaiya ye jo ham parent wali baat kr rhe hai ye bhi smjhado ek baar!!
map<t, list<t> > l;
code me hamne map use kiya hai , graph store karne ke lie.
thik aur map wahi vertex store karega jisme hame koi insertion kiya ho.
kyunki hame vertex 36 pe kabhi koi insertion nahi kiya , map ko pata nahi chalega ki 36 bhi vertex hai.
isiliye jab hum iterate karenge to wo 36 ko kabhi consider nahi kargea
parent me ham ye store kar rahe hai ki hum current vertex se pehle kaun se vertex pe the.
Acha Acha , thik hai bhaiya , Thank you !!.
vo hamesha neighbour hi hoga naa?
ha … … …
bhaiya ek baar code chk krna mera , output sahi ni aari
ab dekhna ->
hanji bhaiya ,
vahi dikkat thi ,
thank you
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.