
MCQs on Graph Representation and Traversal

Quiz
•
Engineering
•
University
•
Medium
mohammed ahmed
Used 1+ times
FREE Resource
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
int[] graph = new int[5];
ArrayList
LinkedList
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
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
Similar Resources on Wayground
25 questions
Geotechnical Engineering Laboratory Quiz

Quiz
•
University
33 questions
bài 1 ktđ

Quiz
•
University
33 questions
Materials Science Quiz

Quiz
•
University
25 questions
Search Algorithms Quiz

Quiz
•
University
25 questions
PTS XI KK TKJ Semester Genap 2024/2025

Quiz
•
11th Grade - University
25 questions
TEMEL ELEKTRONİK

Quiz
•
University
32 questions
Test

Quiz
•
9th Grade - University
30 questions
UTS DPK teknik mesin

Quiz
•
10th Grade - University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Engineering
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University