Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- struct entity {
- int id;
- string ss;
- int parent;
- };
- entity insertNode()
- {
- }
- int main()
- {
- entity tmp;
- vector<entity> vct;
- for(i=0;i<vct.size();i++)
- {
- if(vct[i].parent == -1)
- {
- insertNode(vct[i]); // root hishebe tree te dhukacchi
- queue<entity> Q; // queue nisi jeno root er children dhukaite pari
- Q.push(tmp); // first e root ta dhukailam queue te
- bool cnt = true;
- while(!Q.empty())
- {
- entity lol = Q.top();
- Q.pop(); // top of queue pop korlam
- for(j=0;j<vct.size();j++)
- {
- if(vct[j].parent==lol.id) //current parent er children khujtesi and queue te dhukacchi
- {
- Q.push(vct[j]);
- insertNode(lol, vct[j]);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement