Final answer:
The task is to implement and compare the performance of heapsort and treesort using binary search trees and AVL trees on an array of large random data. Then, compare these algorithms to other sorting methods like quicksort and mergesort.
Step-by-step explanation:
The task involves implementing two sorting algorithms, heapsort and treesort, on a dataset of n=100,000 randomly generated numbers in C++. For treesort, you'll need to create a binary search tree (BST) from the input and then perform an inorder traversal to get the sorted output. For heapsort, a heap is built from the dataset followed by repeatedly calling deleteMin until the heap is empty.
In part 2b, you'll replace the BST in treesort with an AVL tree, which is a self-balancing BST, and compare its performance. Finally, you'll discuss the results of these sorting methods in comparison with other common sorting algorithms like quicksort and mergesort. The AVL tree should yield better performance for treesort on average due to better balance, while heapsort is typically more consistent than treesort given that AVL tree balancing can incur additional operations.
Code Snippets for Heapsort and Treesort
--Heapsort Implementation--
--Treesort Implementation using BST--
--Treesort Implementation using AVL Tree--