How much time does Quicksort take to sort an array of n integers in the average case?
How much time does Quicksort take to sort an array of n integers in the worst case?
Types Cell and Node are shown at the bottom of the page, where Cell is the cell type for a linked list of integers and Node is the node type for a binary search tree. Write a function that takes a binary search tree T and returns a linked list of all of the numbers in T, in ascending order.
Do this by writing a helper function treeToListHelp(T, L) that returns all numbers in tree T, in ascending order, followed by list L. For example, if L = [18, 19, 20] and T holds numbers 4, 8 and 14 (in some structure), then treeToListHelp(T, L) returns list [4, 8, 14, 18, 19, 20]. Then write function treeToList in terms of treeToListHelp.
Cell* treeToListHelp(Node* T, Cell* L)
{
}
Cell* treeToList(Node* T)
{
}
struct Cell
{
Cell* next;
int item;
Cell(int i, Cell* n)
{
item = i;
next = n;
}
};
struct Node
{
int item;
Node* left;
Node* right;
Node(int i, Node* L, Node* R)
{
item = i;
left = L;
right = R;
}
};