MCQs on Graph Representation and Traversal

MCQs on Graph Representation and Traversal

University

30 Qs

quiz-placeholder

Similar activities

Renewable Energy for AB Applications (Reviewer Midterm1)

Renewable Energy for AB Applications (Reviewer Midterm1)

University

28 Qs

STRESS, STRAIN AND DEFORMATION OF SOLIDS

STRESS, STRAIN AND DEFORMATION OF SOLIDS

University

33 Qs

Environmental engineering UNIT 2

Environmental engineering UNIT 2

University

30 Qs

AI502_ML_TA_1_AIDS

AI502_ML_TA_1_AIDS

University

30 Qs

MCQs on Manholes

MCQs on Manholes

University

30 Qs

Variables Aleatorias

Variables Aleatorias

University

25 Qs

S&S CIE-III: MCQ on Unit 5 and 6_ AY 2024-25 Term II

S&S CIE-III: MCQ on Unit 5 and 6_ AY 2024-25 Term II

University

26 Qs

Fluid Mechanics Quiz

Fluid Mechanics Quiz

University

25 Qs

MCQs on Graph Representation and Traversal

MCQs on Graph Representation and Traversal

Assessment

Quiz

Engineering

University

Practice Problem

Medium

Created by

mohammed ahmed

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to initialize an adjacency list for 5 vertices?

ArrayList graph = new ArrayList<>(5);

int[] graph = new int[5];

ArrayList[] graph = new ArrayList[5];

LinkedList[] graph = new LinkedList[5];

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does this code create? graph[0].add(1); graph[1].add(0);

Directed edge from 0 to 1

Undirected edge between 0 and 1

Weighted edge

Cycle

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Why do we initialize each element of the graph? for(int i = 0; i < graph.length; i++) graph[i] = new ArrayList<>();

To make a deep copy

To avoid null pointer exception

To create adjacency matrix

To sort the vertices

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is NOT a correct way to represent an undirected edge between two nodes?

graph[a].add(b); graph[b].add(a);

graph[a].add(b);

graph[b].add(a); graph[a].add(b);

Both A and C

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of using ArrayList[] over ArrayList[]?

To store edge weights

To track edge types

To reduce memory

To make the graph connected

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which data structure does DFS use internally (recursion)?

Queue

Stack

Array

Heap

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the DFS output for this graph starting at 0? 0 - 1 | 2 Code: dfs(graph, 0, visited);

0 1 2

0 2 1

0

2 0 1

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?