Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Topological sort: When an adjacency matrix representation is used, most graph algorithms require time O(n^2) (where n is the number of vertices), but there are

Topological sort:

When an adjacency matrix representation is used, most graph algorithms require time O(n^2) (where n is the number of vertices), but there are some exceptions. Heres one.

Kumiko and her bandmates are having a election to determine the next school band president, and every band member is competing for it. Each candidate has a few preferences (people who the person would be willing to accept as as band president). Of course, the set of preferences for a person includes him/her self all the time.

What we are looking for is a perfect president who is in the set of preferences of every person and who does not prefer anyone but him/her self (wouldnt that make a good president?). In fact, all we want to know whether such a person exists or not. Otherwise, were willing to live in anarchy. Define a directed graph with the set of candidates as the vertices and a directed edge from vertex a to vertex b if and only if b is in the set of preferences of a.

Suppose that the number of people (also the number of candidates) is n. Give an algorithm which executes in O(n) time and determines if such a perfect presidential candidate exists or not. Assume that you are given the graph described above in the form of an n n adjacency matrix.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago