5. Consider the following algorithm to check connectivity of a graph defined by its adjacency matrix. ALGORITHM Connected (A[0..n-1, 0..n-1]) //Input: Adjacency matrix A[0..n - 1, 0..n-1]) of an undirected graph G //Output: 1 (true) if G is connected and 0 (false) if it is not if n = 1 return 1 //one-vertex graph is connected by definition else if not Connected (A[0..n-2, 0..n-2]) return 0 else for j 0 to n - 2 do if A[n 1, j] return 1 return 0 Does this algorithm work correctly for every undirected graph with n > 0 vertices? If you answer yes, indicate the algorithm's efficiency class in the worst case; if you answer no, explain why.
5. Consider the following algorithm to check connectivity of a graph defined by its adjacency matrix. ALGORITHM Connected (A[0..n-1, 0..n-1]) //Input: Adjacency matrix A[0..n - 1, 0..n-1]) of an undirected graph G //Output: 1 (true) if G is connected and 0 (false) if it is not if n = 1 return 1 //one-vertex graph is connected by definition else if not Connected (A[0..n-2, 0..n-2]) return 0 else for j 0 to n - 2 do if A[n 1, j] return 1 return 0 Does this algorithm work correctly for every undirected graph with n > 0 vertices? If you answer yes, indicate the algorithm's efficiency class in the worst case; if you answer no, explain why.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
Please how do I solve number 5?
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps