Given a binary search tree,describe how you could convert it into an AVL tree with worst-case time O(nlogn) and best case O(n)?

I searched that question but didn't understand the answer that is: We can traverse the tree in O(n) time and insert each element into an initially empty AVL tree; this will take O(nlogn) time overall. To get O(n) ‘best-case’ performance we can do something that’s a bit of a hack: try to verify that the BST is a valid AVL tree, which we can do in O(n) time; if it is, return it as it is. Otherwise, create a new AVL tree as described. It’s questionable as to whether this is really a ‘bestcase’ result, as we don’t actually do any conversion, only verification.
What about this answer don't you understand?

Do you understand this bit: "We can traverse the tree in O(n) time"?
Topic archived. No new replies allowed.