Purchase Solution

Maximum cardinality matching algorithm

Not what you're looking for?

Ask Custom Question

A tree is a connected undirected graph with no cycles. Design a linear time algorithm to find a maximum cardinality matching in a tree.

Purchase this Solution

Solution Summary

Maximum cardinality matching algorithm example is provided in the solution.

Solution Preview

Please see the attached.

Algorithm Maximum (T)
Input: T is a rooted tree with n nodes.
Output: A maximum matching M
begin
M←0
number the nodes of T by a BFS (Breadth First Search)
(check the nodes with the backward order of the numbers)
for every node do
if the node or its parent is marked then
skip this node
else
mark its parent
add the edge to M

end
The BFS costs time of O(n) and the loop also costs time of O(n), so the time
complexity of the above algorithm is O(n).

Details:
Suppose T is a tree with a root r(T). Number the nodes by a Breadth First Search (BFS) starting at r(T). Suppose the size of T is n. Number the nodes of T with numbers from 1 to n. The root is ...

Purchase this Solution


Free BrainMass Quizzes
Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Basic Networking Questions

This quiz consists of some basic networking questions.

C# variables and classes

This quiz contains questions about C# classes and variables.

Javscript Basics

Quiz on basics of javascript programming language.