-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
Minimum swaps required to convert binary tree into BST/Tutorial.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
1. Find inorder traversal and store it. | ||
|
||
2. Similar to minimum swaps required to sort an array. | ||
|
||
3. Create a vector and store values with there indexes. | ||
|
||
4. Sort the vector and traverse it, if any value is not present at its correct index, swap it with correct index value and ans++. |