Question #37285

Q28. Consider two undirected trees are represented using adjacency matrix. Write a program which checks whether the tree with less number of vertices is a sub-tree of another tree.


Input File: Contains Adjacency List (Comma separated list of vertices)
InputFile.txt Example
0,1,1,0,0,0,0
1,0,0,1,1,0,0
1,0,0,0,0,0,0
0,1,0,0,0,0,0
0,1,0,0,0,1,1
0,0,0,0,1,0,0
0,0,0,0,1,0,0

------------------------
Input File2 Example
0,1,1,0,0
1,0,0,0,0
1,0,0,1,1
0,0,1,0,0
0,0,1,0,0

------------------------
for example:
Output File:
Yes <FileName1> is sub tree of <FileName2> tree/No
<Node of FileName1> ->[can be represented by] <Node of FileName2> [to assume FileName1 is sub tree of FileName1]
OutputFile.txt Example
Yes,InputFile2 is sub tree of InputFile1 tree
1->2
2->4
3->5
4->6
5->7

Expert's answer

Unfortunately, your question requires a lot of work and cannot be done for free. Please submit it with all requirements as an assignment to our control panel and we'll assist you.
LATEST TUTORIALS
APPROVED BY CLIENTS