Software Development Exam  >  Software Development Tests  >  DSA in C++  >  Test: Graphs - 1 - Software Development MCQ

Test: Graphs - 1 - Software Development MCQ


Test Description

15 Questions MCQ Test DSA in C++ - Test: Graphs - 1

Test: Graphs - 1 for Software Development 2024 is part of DSA in C++ preparation. The Test: Graphs - 1 questions and answers have been prepared according to the Software Development exam syllabus.The Test: Graphs - 1 MCQs are made for Software Development 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Graphs - 1 below.
Solutions of Test: Graphs - 1 questions in English are available as part of our DSA in C++ for Software Development & Test: Graphs - 1 solutions in Hindi for DSA in C++ course. Download more important topics, notes, lectures and mock test series for Software Development Exam by signing up for free. Attempt Test: Graphs - 1 | 15 questions in 30 minutes | Mock test for Software Development preparation | Free important questions MCQ to study DSA in C++ for Software Development Exam | Download free PDF with solutions
Test: Graphs - 1 - Question 1

Which of the following is a correct representation of a graph?

Detailed Solution for Test: Graphs - 1 - Question 1

A graph can be represented using an adjacency matrix, adjacency list, or incidence matrix.

Test: Graphs - 1 - Question 2

In a directed graph, an edge from vertex A to vertex B means:

Detailed Solution for Test: Graphs - 1 - Question 2

In a directed graph, an edge from vertex A to vertex B means that there is a directed edge from A to B.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Graphs - 1 - Question 3

What is the time complexity of Breadth First Search (BFS) on a graph with V vertices and E edges?

Detailed Solution for Test: Graphs - 1 - Question 3

The time complexity of BFS on a graph with V vertices and E edges is O(V + E).

Test: Graphs - 1 - Question 4

What is the purpose of visited[] array in Depth First Search (DFS)?

Detailed Solution for Test: Graphs - 1 - Question 4

The visited[] array is used in DFS to keep track of the visited vertices.

Test: Graphs - 1 - Question 5

Which traversal algorithm uses a stack data structure to explore vertices?

Detailed Solution for Test: Graphs - 1 - Question 5

DFS uses a stack data structure to explore vertices.

Test: Graphs - 1 - Question 6

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;
}

Detailed Solution for Test: Graphs - 1 - Question 6

The given code initializes a 2D vector 'graph' and accesses the element at index [1][1], which is 2.

Test: Graphs - 1 - Question 7

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;
}

Detailed Solution for Test: Graphs - 1 - Question 7

The code creates a queue, pushes elements 10, 20, and 30 into it, then pops the front element. Finally, it prints the front element, which is 20.

Test: Graphs - 1 - Question 8

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;
}

Detailed Solution for Test: Graphs - 1 - Question 8

The code creates a stack, pushes elements 10, 20, and 30 into it, then pops an element. Finally, it prints the top element, which is 20.

Test: Graphs - 1 - Question 9

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;
}

Detailed Solution for Test: Graphs - 1 - Question 9

The code creates a queue, pushes elements 10, 20, and 30 into it, and then prints the back element, which is 30.

Test: Graphs - 1 - Question 10

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;
}

Detailed Solution for Test: Graphs - 1 - Question 10

The given code tries to access the element at index 4, which is out of bounds of the vector 'v'.

Test: Graphs - 1 - Question 11

Which traversal algorithm can be used to find the shortest path between two vertices in an unweighted graph?

Detailed Solution for Test: Graphs - 1 - Question 11

BFS can be used to find the shortest path between two vertices in an unweighted graph.

Test: Graphs - 1 - Question 12

Which graph representation is more space-efficient when the graph has fewer edges compared to vertices?

Detailed Solution for Test: Graphs - 1 - Question 12

Adjacency list representation is more space-efficient when the graph has fewer edges compared to vertices.

Test: Graphs - 1 - Question 13

Which of the following statements is true regarding Depth First Search (DFS)?

Detailed Solution for Test: Graphs - 1 - Question 13

DFS can be used to detect cycles in a graph.

Test: Graphs - 1 - Question 14

Which of the following algorithms can be used to find the longest path in a graph?

Detailed Solution for Test: Graphs - 1 - Question 14

The Bellman-Ford algorithm can be used to find the longest path in a graph.

Test: Graphs - 1 - Question 15

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:

Detailed Solution for Test: Graphs - 1 - Question 15

If there is a path from vertex A to vertex B and a path from vertex B to vertex A in a directed graph, it is called a strongly connected graph.

153 videos|115 docs|24 tests
Information about Test: Graphs - 1 Page
In this test you can find the Exam questions for Test: Graphs - 1 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Graphs - 1, EduRev gives you an ample number of Online tests for practice

Top Courses for Software Development

153 videos|115 docs|24 tests
Download as PDF

Top Courses for Software Development