| Operation | Adjacency list | Adjacency matrix | 
| Is v1 adjacent to v2? | O(|V|) | O(|1|) | 
| For a single vertex, find all vertices adjacent to that vertex | O(|V|) | O(|V|) | 
| For each (every) vertex, find all vertices adjacent to that vertex | O(|V|+|E|) | O(|V|2) | 
| Total space required. | O(|V|+|E|) | O(|V|2) | 
O(|V|)            -- mark all vertices as unvisited
O(1)              -- insert the start vertex into an empty collection C
O(|V|) iterations -- while (C not empty)
  O(1)                 - remove a vertex v from C
  O(1)                 - if v has not been visited
     O(1)                    * visit v
     O(|V|)(adj matrix)           * insert all univisted adjacent nodes to v into C
     O(|E|/|V|)(adj list)
Total complexity is O(|V|2) for an adjacency matrix, O(|V|+|E|) for an
adjacency list.
Answer:O(NlogN). N elements must be inserted, which involves adding the element as the last leaf (O(1)), then reheapifying (bubbling it up to where it really goes). If every element had to traverse the entire height of the N-element tree during reheapification, the complexity would be O(N)(the number of elements) * O(log N) the height of the tree. Of course, not all elements have to go that far; only the elements inserted at the leaves do. But there are N/2 elements at the leaves, so this gives N/2 * O(log N) which is still O(NlogN) for the total complexity.
Answer:O(N). First the algorithm: Assume we want to build a max heap. First insert all elements, in arbitrary order, into the heap (array). Then:
    0*N/2 + 1*N/4 + 2*N/8 + 3*N/16 + 4*N/32 + ... + (logN-1)*N/N
=   N(1/4 + 2/8 + 3/16 + 4/32 + ... + (logN-1)/N)
Although this probably is not a familiar sequence for you, it is easy to
believe that it sums to a constant, giving a complexity of O(N).
-- Do a linear search to find the element in the heap (O(N)) -- Replace that element with the last element in the heap (O(1)) -- Bubble the new element up or down, as necessary, to put it in place (O(logN))Total complexity: O(N) + O(1) + O(logN) = O(N).
Answer: If the elements might be unevenly distributed, it's O(N). (In the worst case they're all in a single linked list in the same bucket.) If the elements are evenly distributed, it depends on the size of the hash table. If the hash table is of fixed size S, then on average each bucket has N/S elements, which is O(N). However, if the size of the hash tables varies with N, so it is kN (where k would usually be less than 1), then on average each bucket has N/(kN) = 1/k elements, which is a constant.