COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Depends on the number of vertices
|
|
Depends on the number of edges
|
|
It depends on both the number of edges and vertices
|
|
Is independent of both the number of edges and vertices
|
Detailed explanation-1: -On which of the following statements does the time complexity of checking if an edge exists between two particular vertices is not, depends? Explanation: To check if there is an edge between to vertices i and j, it is enough to see if the value of A[i][j] is 1 or 0, here A is the adjacency matrix . 8.
Detailed explanation-2: -time complexity is O(∣V∣)
Detailed explanation-3: -9. What would be the time complexity of the following function which adds an edge between two vertices i and j, with some weight ‘weigh’ to the graph having V vertices? Explanation: The function win in the constant time as all the four step takes constant time.
Detailed explanation-4: -Time complexity is O(v + e) for an adjacency list.
Detailed explanation-5: -Hence, time complexity to calculate number of edges is O(V2)