Skip to content

Commit

Permalink
Merge pull request #1772 from 17Moons/17Moons-contribution
Browse files Browse the repository at this point in the history
17 moons contribution
  • Loading branch information
fineanmol authored Oct 1, 2022
2 parents 6c368cd + 26c49f1 commit ed03cc5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 129 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
void vTraversal(Node *root)
{
map<int, vector<int>> mp;
queue<pair<Node *, int>>q;
q,push({root,0});
while(q.empty()==false)
{
auto p = q.front();
Node *curr = p.first;
int hd = p.second;
mp[hd].push_back(curr->data);
q.pop();
if(curr->left != NULL)
{
q.push({curr->left, hd-1});
}
if(curr->right != NULL)
{
q.push({curr->right, hd+1});
}
}


for(auto p: mp)
{
vector <int> v =p.second;
for(int x: v)
{
cout<<c<<" ";
cout<<endl;
}
}
}
128 changes: 0 additions & 128 deletions README.md

This file was deleted.

1 change: 0 additions & 1 deletion readme.md

This file was deleted.

0 comments on commit ed03cc5

Please sign in to comment.