LevelOrderTreaversal + SelectionSort [Cpp] 
Approach :
LevelOrderTraversal + selection sort
Complexity
Time complexity: O(n∗n)

Space complexity: O(n)
Code


# Approach : 
- LevelOrderTraversal + selection sort 
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: $$O(n*n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(n)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int helper(vector<int> arr, int swaps) {

        int n = arr.size();

        
        vector<int> sortedArr = arr;
        sort(sortedArr.begin(), sortedArr.end());

      for(int i = 0; i < n ; i++){

        while(arr[i] != sortedArr[i]){
          int idx = find(arr.begin(),arr.end(),sortedArr[i]) - arr.begin();
            swap(arr[i],arr[idx]);
            swaps++;
        }
      };
        return swaps;
    }
 int minimumOperations(TreeNode* root) {
    int ans = 0;
    queue<TreeNode*> nod;
    if (root == NULL)
        return ans;
    nod.push(root);
    while (!nod.empty()) {
        vector<int> temp;
        int size = nod.size();
        for (int i = 0; i < size; i++) {
            TreeNode* ptr = nod.front();
            nod.pop();

            temp.push_back(ptr->val);
            if (ptr->left)
                nod.push(ptr->left);
            if (ptr->right)
                nod.push(ptr->right);
        }
       int t =  helper(temp, 0);
       ans += t;
        temp.clear();
    }
    return ans;
}
};

```
['Tree', 'Binary Tree', 'C++']