Suppose the adjacency relation of vertices in a graph is represented in a…
2001
Suppose the adjacency relation of vertices in a graph is represented in a table Adj (X, Y). Which of the following queries cannot be expressed by a relational algebra expression of constant length?
- A.
List of all vertices adjacent to a given vertex
- B.
List all vertices which have self-loops
- C.
List all vertices which belong to cycles of less than three vertices
- D.
List all vertices reachable from a given vertex
Attempted by 71 students.
Show answer & explanation
Correct answer: D
The query that cannot be expressed by a relational algebra expression of constant length is the one involving reachability from a given vertex. This is because reachability requires computing the transitive closure of the adjacency relation, which involves paths of arbitrary length. Relational algebra does not support recursion or iteration, so it cannot express queries that depend on unbounded path lengths in constant length. The other options—listing adjacent vertices, self-loops, and cycles of less than three vertices—can all be expressed using finite joins and selections, which are expressible in constant-length relational algebra.
A video solution is available for this question — log in and enroll to watch it.