Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct entity {
  5. int id;
  6. string ss;
  7. int parent;
  8. };
  9.  
  10. entity insertNode()
  11. {
  12.  
  13. }
  14.  
  15. int main()
  16. {
  17. entity tmp;
  18. vector<entity> vct;
  19. for(i=0;i<vct.size();i++)
  20. {
  21. if(vct[i].parent == -1)
  22. {
  23. insertNode(vct[i]); // root hishebe tree te dhukacchi
  24. queue<entity> Q; // queue nisi jeno root er children dhukaite pari
  25. Q.push(tmp); // first e root ta dhukailam queue te
  26. bool cnt = true;
  27. while(!Q.empty())
  28. {
  29. entity lol = Q.top();
  30. Q.pop(); // top of queue pop korlam
  31. for(j=0;j<vct.size();j++)
  32. {
  33. if(vct[j].parent==lol.id) //current parent er children khujtesi and queue te dhukacchi
  34. {
  35. Q.push(vct[j]);
  36. insertNode(lol, vct[j]);
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement