All Exams Test series for 1 year @ ₹349 only
Question

Which of the following statements are TRUE, where $|E|$ represents the number of edges.
(A). In case of a directed graph, the sum of lengths of all the adjacency list is $|E|$
(B). For an undirected graph, the sum of the lengths of all the adjacency list is $2|E|$
(C). For a dense graph, adjacency matrix representation is preferable
(D). The memory requirement of the adjacency matrix of a graph is dependent on the number of edges
Choose the correct answer from the options given below:
1. (A), (B) and (D) only
2. (A), (B) and (C) only
3. (A), (B), (C) and (D)
4. (B), (C) and (D) only

The correct answer is
(A), (B) and (C) only

This solution analyzes the truthfulness of four statements concerning graph data structures, specifically focusing on adjacency lists and adjacency matrices for both directed and undirected graphs.

Analyzing Statement (A): Directed Graph Adjacency List Sum

This statement concerns directed graphs and the sum of the lengths of their adjacency lists. In a directed graph, an edge from vertex u to vertex v is represented by adding v to the adjacency list of u. Each directed edge corresponds to exactly one entry in one adjacency list (the list of its source vertex).

  • Let the graph have $|V|$ vertices and $|E|$ edges.
  • For each vertex u, its adjacency list stores all vertices v such that there is a directed edge (u, v).
  • The length of the adjacency list for vertex u is its out-degree.
  • The sum of the lengths of all adjacency lists is the sum of the out-degrees of all vertices.
  • By the handshaking lemma for directed graphs, the sum of out-degrees is equal to the total number of edges, $|E|$.

Therefore, statement (A) is TRUE.

Analyzing Statement (B): Undirected Graph Adjacency List Sum

This statement deals with undirected graphs and the sum of lengths of their adjacency lists. In an undirected graph, an edge between vertices u and v means that v is in the adjacency list of u, and u is in the adjacency list of v.

  • Consider an undirected edge {u, v}.
  • This edge contributes one entry to the adjacency list of u (listing v) and one entry to the adjacency list of v (listing u).
  • So, each undirected edge accounts for two entries in total across all adjacency lists.
  • If there are $|E|$ edges in total, the sum of the lengths of all adjacency lists will be $2 \times |E|$.

Therefore, statement (B) is TRUE.

Analyzing Statement (C): Dense Graph Adjacency Matrix Preference

This statement discusses the preference for adjacency matrix representation in dense graphs. A dense graph is one where the number of edges, $|E|$, is close to the maximum possible number of edges, which is approximately $|V|^2$ for a graph with $|V|$ vertices.

  • Adjacency Matrix: Uses $O(|V|^2)$ space. Checking for an edge takes $O(1)$ time. Iterating through neighbors of a vertex takes $O(|V|)$ time.
  • Adjacency List: Uses $O(|V| + |E|)$ space. Checking for an edge can take up to $O(\text{degree}(v))$ time. Iterating through neighbors takes $O(\text{degree}(v))$ time.
  • In a dense graph, $|E|$ is approximately $O(|V|^2)$. So, the space complexity for both representations becomes similar, $O(|V|^2)$.
  • However, for dense graphs, the constant-time edge lookup ($O(1)$) provided by the adjacency matrix is often more advantageous than the potential linear time lookup in adjacency lists (proportional to the degree, which is high in dense graphs). The simplicity and direct access make the matrix preferable for operations like checking edge existence frequently.

Therefore, statement (C) is TRUE.

Analyzing Statement (D): Adjacency Matrix Memory Dependency

This statement claims that the memory requirement of an adjacency matrix is dependent on the number of edges ($|E|$). Let's examine the memory requirements for graph representations.

  • Adjacency Matrix: It is a two-dimensional array (matrix) of size $|V| \times |V|$, where $|V|$ is the number of vertices. The memory required is always proportional to the square of the number of vertices, i.e., $O(|V|^2)$, regardless of how many edges are actually present.
  • Adjacency List: The memory required is proportional to the sum of the number of vertices and the number of edges, i.e., $O(|V| + |E|)$. This representation's memory *is* dependent on the number of edges.

Since the memory for an adjacency matrix depends on $|V|^2$ and not $|E|$, statement (D) is FALSE.

Summary and Final Answer

Based on the analysis:

  • Statement (A) is TRUE.
  • Statement (B) is TRUE.
  • Statement (C) is TRUE.
  • Statement (D) is FALSE.

The statements that are true are (A), (B), and (C).

Matching this with the given options, the correct choice is the one that includes only (A), (B), and (C).

Was this answer helpful?

Important Questions from Miscellaneous

  1. Which of the following scheduler/schedulers is/are also called CPU scheduler ?
    (A). Short Term Scheduler
    (B). Long Term Scheduler
    (C). Medium Term Scheduler
    (D). Asymmetric Scheduler
    Choose the correct answer from the options given below:
  2. A situation where two or more processes are blocked, waiting for resources held by each other is called:
  3. External fragmentation occurs ________.
  4. Which disk scheduling algorithm looks for the track closest to the current head position?
  5. Which CPU scheduling algorithm prefers the process with the shortest burst time?
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App