For this Question: Traverse through the tree according to preorder traversal and print the elements of the tree while traversing.The first line of the input contains an integer N, the number of nodes in the tree.
The N lines contains two integers s, d representing parent and child
Constraints
2 <= N <= 100000
1 <= s, d <= 100000

Print the nodes in pre-order traversal.Input
5
1 2
1 3
2 4
2 5
Output:1 2 4 5 3


Input: 
5
1 2
1 3
1 4
4 5
Output: 1 2 3 4 5, I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;

#define pu push_back
#define fi first
#define se second
#define mp make_pair
#define int long long
#define pii pair<int,int>
#define mm (s+e)/2
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define sz 200000

vector<int> NEB[sz];

void dfs(int s,int f)
{
	  cout<<s<<" ";
	for(auto it:NEB[s])
	{
		if(it!=f)
		{
			dfs(it,s);
		}
	}
}
signed main()
{
	
		
		int n;
		cin>>n;
		for(int i=0;i<n-1;i++)
		{
          int a,b;
          cin>>a>>b;
          NEB[a].pu(b);
          NEB[b].pu(a);
		}
		for(int i=1;i<=n;i++)
		{
			sort(NEB[i].begin(),NEB[i].end());
		}
        dfs(1,-1);



	
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?