Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. [15pts] Suppose we have the following parent implementation of a forest representing a partition of a set of 17 elements: a. Sketch the trees

image text in transcribed
3. [15pts] Suppose we have the following parent implementation of a forest representing a partition of a set of 17 elements: a. Sketch the trees in F. b. Show the state of Parenf[0:16] after a call to Union ( Parenf [0,16],1,8) and sketeh the tress in F. c. Given the state of Parewr (0:16) in part (b), show the state of Paresid0:16] after an invocation of Find2(Parewi[0:16],4) and sketch the trees in F. Programming Project (60pts) Connected Components of a Network The topology of a network is modeled with a graph. Write a C++ program that inputs a graph G by first inputting the number of vertices n followed by a sequence of puirs i.1 where i and j are integers between 0 and n1, inclusive, repesenting the edges of the graph, and ending with a negative integer sentinel to indicate the end of the input. For example, 501142313341 represents the graph G=(VE) given by: y={0,1,2,3,4}E={{0,1},{1,4},{2,3},{1,3},{3,4}}. Your program will compute the (connecied) components of G. You can procecd as follows - Implement the graph G with using pointer-based adjacency lists fusing an array of beader nodes and a finked list for each header node). Your class Graph should include constructors and a destructor, operations of edge addition, odge deletion, ctc., - Implement the function DPS (G,v) for performing a depth-first search. - Implement a function Components (G) for computing the vertex sets of the connected components of G. Component a (\} will employ a DFT (Depth-First Travenal), which involves calling DFS (G,v),v=0,1,n1. For purposes of grading, store the entire source code, including the graph class and its implementation, in a single exp file. Your program should nin using Visual C+. . Have your program outpot the adjacescy matrix of the graph as well as the connected components. Output the components by outpuating the vertes set of each component. Run your ptogram for a disconnected graph (Le, having at least two components) of your choosing and subenit this outpot in additional to your soarce code. Your program should be user-fricndly, well-commented, with the output welldocemented

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To answer the question lets tackle each part step by step a Sketch the trees in F Given the Parent a... 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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions