I've read through the wiki page and other StackOverflow answers. Hoping someone can explain what these two algorithms do.
Thank you
Treesort uses the inorder traversal performed over binary search tree (BST). Building a BST of n
items take O(n * depth of tree) = O(n * log n)
time.
Heapsort works on the logic that the largest item is stored at the root of the heap. Building a heap of n
items take O(n * each_heapify_TimeComplexity) = O(n * log n)
time.
For screwed tree structure, Treesort's TC would be O(n^2)
. While Heapsort is different in this perspective, as it keeps the depth to minimal possible value by shaping itself as a complete binary tree.