Converting Binary Tree to Binary Search Tree without changing spatial structure

preview_player
Показать описание
Converting Binary Tree to Binary Search Tree without changing spatial structure
Рекомендации по теме
Комментарии
Автор

Cannot hope for better explanation than this . It was smooth and clear 👌

goodpeople
Автор

Dear Friends,

If you like our content and would like us to continue making great content for you, please spread the word about IDeserve.
A share/appreciation from you on social network would mean the world to us!


Thanks,
-Team IDeserve.

IDeserve
Автор

This is the best explanation and visualization that I have seen for BT to BST conversion. well done!

JamesStiling
Автор

A note, We can do any traversal not just IN.ORDER. After traversing, sort the array, and replace accordingly

Kriishna
Автор

Hi,
I just wanted to know that id the data of binary tree is anyway given in an unsorted to form then why are we traversing it first and then sorting and traversing simultaneously. why don't we sort it in the beginning itself.
Thanks,
Divya

DivyaPaliwal
Автор

Just a little note
When it comes to scalability, using array to store a traversal or any data related to tree which have space of order O( n ) is a bad idea.
Why?
Let's take my computer for example, it doesn't allow size of array more than 10^5, It will close in runtime.
but a tree with 10^5 nodes is normal
lets say a height balanced tree has height 30 than it will have 10^9 approx nodes
So your code will crash for such inputs

To solve this whenever you want to store something, use lInked lists which can store too much data

A tiny modification on this code and it will support linked list

A Request :
You guys have covered how to make a balanced BST tree form Array in O( n ) time
You guys should also cover how to make balanced BST directly from Linked List without using any array in O( n ) time

charvakpatel
Автор

Can we use this method to convert min heap to BST?

codeworld
Автор

Is there a way that we can balance this as well?

alexsugarman
join shbcf.ru