Skip to content
Official PYQ · 2001

GATE CS 2001 Q1.24 — Relational Model: Relational Algebra

Explain with AI

Suppose the adjacency relation of vertices in a graph is represented in a table Adj (X,Y).(X,Y). Which of the following queries cannot be expressed by a relational algebra expression of constant length?

Choose one option
View worked solution

Answer: D

To determine which query cannot be expressed by a relational algebra (RA) expression of constant length, let's analyze each option:

  • Option A: List all vertices adjacent to a given vertex vv
    This requires a simple selection and projection: πY(σX=v(Adj))\pi_{Y}(\sigma_{X = v}(\text{Adj})) This is of constant length.
  • Option B: List all vertices which have self-loops
    A self-loop occurs when a vertex is adjacent to itself (X=YX = Y): πX(σX=Y(Adj))\pi_{X}(\sigma_{X = Y}(\text{Adj})) This is of constant length.
  • Option C: List all vertices which belong to cycles of less than three vertices
    Cycles of length less than 3 can only be of length 1 (self-loops) or length 2 (where u→vu \to v and v→uv \to u with u≠vu \neq v).
    • Cycles of length 1: C1=πX(σX=Y(Adj))C_1 = \pi_{X}(\sigma_{X=Y}(\text{Adj})).
    • Cycles of length 2: C2=πX(σX=Y1∧Y=X1∧X≠Y(Adj(X,Y)⋈ρAdj1(X1,Y1)(Adj)))C_2 = \pi_{X}(\sigma_{X = Y_1 \land Y = X_1 \land X \neq Y}(\text{Adj}(X, Y) \bowtie \rho_{\text{Adj1}(X_1, Y_1)}(\text{Adj}))).
    The union C1∪C2C_1 \cup C_2 gives the desired set, which is of constant length.
  • Option D: List all vertices reachable from a given vertex
    Finding all reachable vertices in an arbitrary graph requires computing the transitive closure of the adjacency relation. Since the number of vertices nn is not fixed, the path length can be arbitrarily large. Standard relational algebra lacks recursion or looping constructs, meaning we cannot write a single, fixed-length expression to compute transitive closure for graphs of arbitrary size.

Therefore, reachability (Option D) cannot be expressed by a relational algebra expression of constant length.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Relational Model: Relational Algebra questions