Work the exercises for quiz 11 again. Similar questions will be on quiz 12 too. Here are some additional questions.
Which of the following is true about log2(1500)?
To within a constant factor, how much time does it take, on average, to look up a value into a hash table that has n values in it?
To within a constant factor, how much time does it take, on average, to insert a value into a hash table that has n values in it?
Would a hash table be a useful tool for sorting an array? Why or why not?
Suppose that a linked list is used to store a set of numbers. If there are n numbers in the list, how long, to within a constant factor, does it take to check whether a given number is in the list, in the worst case?
Write a C++ definition of function insert(x, L) that inserts x into linked list L, modifying list L. It does not matter where in the list x ends up. It can be at the beginning or at the end or anywhere in between. The heading should be
void insert(int x, Cell*& L)Type Cell is shown at the bottom of the page.
Write a C++ definition of function remove(x, L) that removes the first occurrence of x from linked list L, modifying list L. If x does not occur in L, then remove(x, L) should not make any changes. There should be no memory leak. The heading should be
void remove(int x, Cell*& L)
struct Cell { Cell* next; int item; Cell(int i, Cell* n) { item = i; next = n; } };