Algorithms and Data Structures (INF1, Autumn'05)

Exercise Set 12



Exercise 1:

Let G=(V,E) be a digraph where n is the number of nodes and m is the number of edges. Let us now consider the space complexity of adjacency matrix and adjacency list implementation of digraphs. Fill in the following table when certain relationships between the number of nodes and edges are know (use big-O notation).


Adjacency Matrix Adjacency List
nothing is known about n and m    
m = O(n)    
m = Ω(n2)    
n = Ω(m2)    
m = O(n*log n)    

Which representation is more space efficient? Which cases above demonstrate this? Can you characterize them in words? In which cases adjacency matrix and adjacency list requite approximately the same space?


Exercise 2:



Exercise 3:

Using the operations of the ADT DIGRAPH construct g:DIGRAPH representing the following directed graph G=(V,E) where V= {A, B, C, D} and E= {(A,B), (B,B), (C,D)} such that the names of the edges are 1, 3 and 7 (in this order).