Question
vector<int> adjacent[15] ;
vector<int> weight[15];
void addEdge(int i,int j,int weigh)
{
adjacent[a].push_back(i);
adjacent[b].push_back(j);
weight[a].push_back(weigh);
weight[b].push_back(weigh);
}
a.
O(1)
b.
O(V)
c.
O(V*V)
d.
O(log V)
Posted under Data Structures and Algorithms
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. 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?
Similar Questions
Discover Related MCQs
Q. Given a plane graph, G having 2 connected component, having 6 vertices, 7 edges and 4 regions. What will be the number of connected components?
View solution
Q. Number of vertices with odd degrees in a graph having a eulerian walk is ________
View solution
Q. How many of the following statements are correct?
i) All cyclic graphs are complete graphs.
ii) All complete graphs are cyclic graphs.
iii) All paths are bipartite.
iv) All cyclic graphs are bipartite.
v) There are cyclic graphs which are complete.
View solution
Q. All paths and cyclic graphs are bipartite graphs.
View solution
Q. What is the number of vertices of degree 2 in a path graph having n vertices,here n>2.
View solution
Q. All trees with n vertices consists of n-1 edges.
View solution
Q. What would the time complexity to check if an undirected graph with V vertices and E edges is Bipartite or not given its adjacency matrix?
View solution
Q. Dijkstra’s Algorithm will work for both negative and positive weights?
View solution
Q. A graph having an edge from each vertex to every other vertex is called a ___________
View solution
Q. What is the number of unlabeled simple directed graph that can be made with 1 or 2 vertices?
View solution
Q. Floyd Warshall Algorithm used to solve the shortest path problem has a time complexity of __________
View solution
Q. All Graphs have unique representation on paper.
View solution
Q. Assuming value of every weight to be greater than 10, in which of the following cases the shortest path of a directed weighted graph from 2 vertices u and v will never change?
View solution
Q. What is the maximum possible number of edges in a directed graph with no self loops having 8 vertices?
View solution
Q. What is the maximum number of edges present in a simple directed graph with 7 vertices if there exists no cycles in the graph?
View solution
Q. Every Directed Acyclic Graph has at least one sink vertex.
View solution
Q. With V(greater than 1) vertices, how many edges at most can a Directed Acyclic Graph possess?
View solution
Q. The topological sorting of any DAG can be done in ________ time.
View solution
Q. If there are more than 1 topological sorting of a DAG is possible, which of the following is true.
View solution
Q. Which of the given statement is true?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!