a. | O(1) | d. | O(n*log(n)) |
b. | O(log(n)) | e. | O(n*n) |
c. | O(n) | f. | O(2^n) |
For each action below, state the smallest of the functions above that characterizes the worst case running time of the action. In other words, if the action has a worst case running time of 4n+3, then the answer is c, not d or e.
Part 1: | Appending an item to the end of a Dllist with n elements. |
Part 2: | Inserting an element into a splay tree with n elements. |
Part 3: | Inserting an element into an AVL-tree with n elements. |
Part 4: | Finding an element in a hash table that uses linear probing with n elements. Assume that the table size is much larger than n. |
Part 5: | Performing a postorder traversal of a binary tree with n elements. |
Part 6: | Performing a zig-zag rotation on a splay tree with n elements. |
Part 7: | Inserting n elements into a splay tree with n elements in it. |
Part 8: | Inserting n elements into an AVL tree with n elements in it. |
Part 9: | Inserting n elements in ascending order into an empty binary search tree. |
Part 10: | Sorting a file with n lines, using red-black trees. |
|