1 Crore+ students have signed up on EduRev. Have you? Download the App |
What is the time complexity of Breadth First Search (BFS) on a graph with V vertices and E edges?
What is the purpose of visited[] array in Depth First Search (DFS)?
Which traversal algorithm uses a stack data structure to explore vertices?
What will be the output of the following code?
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<vector<int>> graph = {{1, 2}, {2, 3}, {3, 1}};
cout << graph[1][1];
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <queue>
using namespace std;
int main() {
queue<int> q;
q.push(10);
q.push(20);
q.push(30);
q.pop();
cout << q.front();
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <stack>
using namespace std;
int main() {
stack<int> s;
s.push(10);
s.push(20);
s.push(30);
s.pop();
cout << s.top();
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <queue>
using namespace std;
int main() {
queue<int> q;
q.push(10);
q.push(20);
q.push(30);
cout << q.back();
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> v = {1, 2, 3, 4};
cout << v[4];
return 0;
}
Which traversal algorithm can be used to find the shortest path between two vertices in an unweighted graph?
Which graph representation is more space-efficient when the graph has fewer edges compared to vertices?
Which of the following statements is true regarding Depth First Search (DFS)?
Which of the following algorithms can be used to find the longest path in a graph?
In a directed graph, if there is a path from vertex A to vertex B and a path from vertex B to vertex A, it is called:
153 videos|115 docs|24 tests
|
153 videos|115 docs|24 tests
|