100 / \ 50 300 / / \ 25 125 400 / \ \ 110 200 500 \ 250 / 225
300 / \ 175 400 \ 250 / \ 200 275
20 / \ 10 40 / \ 8 16 / 12
a b c




For each fragment of code, please circle its BigO running time:
a O(1) O(log n) O(n) O(n log n) O(n^{2}) O(n^{3}) O(2^{n}) b O(1) O(log n) O(n) O(n log n) O(n^{2}) O(n^{3}) O(2^{n}) c O(1) O(log n) O(n) O(n log n) O(n^{2}) O(n^{3}) O(2^{n}) d O(1) O(log n) O(n) O(n log n) O(n^{2}) O(n^{3}) O(2^{n})
Operation  Average Case  Worst Case 

Inserting an element into a hash table that uses separate chaining 

Finding an element in a binary search tree  
Inserting an element into an AVL tree  
Adding an element to the front of a vector  
Removing an element from the top of a stack (i.e., pop) 
a. array b. vector c. stack d. deque e. hash table f. list g. binary search tree h. AVL tree i. BTree
For each of the following questions choose the best answer from the above list. Assume that the size of an array is fixed once it is created, and that its size cannot be changed thereafter. Sometimes it may seem as though two or more choices would be equally good. In those cases think about the operations that the data structures support and choose the data structure whose operations are best suited for the problem. You may have to use the same answer for more than one question: