Question

Hi, Can you help me know the kind of parameter do I pass while I call...

Hi, Can you help me know the kind of parameter do I pass while I call the function "printParents" below. This is a program to detect if the graph is Bi-Partite or not using a DFS algorithm. I will have follow up questions on this. Thank you!

public void printParents (PrintWriter output) {
int v;
output.println("Parents in BFS tree:");
output.printf ("Vertex: ");
for (v = 1; v <= nVertices; v++)
output.printf ("%2d ", v);
output.println();
output.printf("Parent: ");
for (v = 1; v <= nVertices; v++)
output.printf ("%2d ", vertices[v].parent);
output.println();
}// end of printParents

0 0
Add a comment Improve this question Transcribed image text
Answer #1

To call the printParents function you need to pass the PrintWriter class object because in the method they are writing the statements to a file

So you should open an file for the same

// you shoud name your file accordingly

PrintWriter pw = new PrintWriter("output.txt");

so now you need to pass pw to printParents method

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Hi, Can you help me know the kind of parameter do I pass while I call...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You will be implementing a Breadth-First Search (BFS) and a Depth-First Search (DFS) algorithm on a...

    You will be implementing a Breadth-First Search (BFS) and a Depth-First Search (DFS) algorithm on a graph stored as an adjacency list. The AdjacencyList class inherits from the Graph class shown below. class Graph { private: vector _distances; vector _previous; public: Graph() { } virtual int vertices() const = 0; virtual int edges() const = 0; virtual int distance(int) const = 0; virtual void bfs(int) const = 0; virtual void dfs(int) const = 0; virtual void display() const = 0;...

  • refer to the question using c++. if you could not do the bonus part no problem you don't have too , but if you can so please do it and let me know Create an unweighted undirected Graph Class usin...

    refer to the question using c++. if you could not do the bonus part no problem you don't have too , but if you can so please do it and let me know Create an unweighted undirected Graph Class using an Adjacency Matrix with the following functions 1. Graph(int numofV) 3. int noOfOutgoingEdges(int vertex); 4. int noOflncomingEdges (int vertex) 5. void print) You may use vectors/2D dynamic arrays to implement the matrix. Bonus (20) 6. void DFS(); Depth First Search...

  • I have a Graph.java which I need to complete four methods in the java file: completeGraph(),...

    I have a Graph.java which I need to complete four methods in the java file: completeGraph(), valence(int vid), DFS(int start), and findPathBFS(int start, int end). I also have a JUnit test file GraphTest.java for you to check your code. Here is Graph.java: import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; /* Generic vertex class */ class Vertex<T> { public T data; public boolean visited; public Vertex() { data = null; visited = false; } public Vertex(T _data) { data =...

  • Help !! I need help with Depth-First Search using an undirected graph. Write a program, IN JAVA, ...

    Help !! I need help with Depth-First Search using an undirected graph. Write a program, IN JAVA, to implement the depth-first search algorithm using the pseudocode given. Write a driver program, which reads input file mediumG.txt as an undirected graph and runs the depth-first search algorithm to find paths to all the other vertices considering 0 as the source. This driver program should display the paths in the following manner: 0 to ā€˜v’: list of all the vertices traversed to...

  • Does not pass the testcase testDTreeAdvancedReRootchangesParent Java I'm trying to extend the implementation of a general...

    Does not pass the testcase testDTreeAdvancedReRootchangesParent Java I'm trying to extend the implementation of a general tree with new operations that change the structure of the tree. I've created 5 classes: Node.java, SimpleNode.java, Tree.java, RerootableTree.java and SimpleTree.java(which is the main java class that I need to change). The code does not pass ONE TESTCASE : testDTreeAdvancedReRootchangesParent The code passes all the other testcases except theone mentioned above. This is because in the SimpleTree.java the method "reRoot(Node newRoot)" is most likely...

  • Hi, I do not know what to do with these three questions. Please help me with...

    Hi, I do not know what to do with these three questions. Please help me with them. I so appreciate! Thank you! 1. Applying the results of a study of the National Basketball Association would lead you as a college coach to encourage touching among teammates in the hope of improving your team's performance. Group of answer choices: True False 2. You don't want your parents to know you borrowed their car while they were away on vacation. Your parents...

  • Can someone please help me fix my code on this assignment that's due in the morning?...

    Can someone please help me fix my code on this assignment that's due in the morning? Please read the question carefully. Using C++, construct a graph class, graph.template, in which the edges are stored in adjacency sets. You need to use graph.h and test_graph.cpp to implement graph.template. The author provides an implementation of a graph using an adjacency matrix. I have started the template file but I cannot get it to compile. I have posted my template file of what...

  • Hi, I hope I can get some help with the following exercise in C++( CPP): 1.Write...

    Hi, I hope I can get some help with the following exercise in C++( CPP): 1.Write an additional method called push_back(int) that will add an integer to the end of the list. You can modify the provided code. 2.Modify the Node class and LinkedList class so that you can access your parent node (double linked-list). /* definition of the list node class */ class Node { friend class LinkedList; private: int value; Node *pNext; public: /* Constructors with No Arguments...

  • Hi, I need help with this question to my coding assignment. I completed letter A in...

    Hi, I need help with this question to my coding assignment. I completed letter A in the remaining program I just need help with letter "B" and by the way this is C programming. If you can't do it, just explain to me in very simple terms what I would do. void updateScores(int scoreCard[CATEGORIES][COLS], int category,int dice [5]) { switch(category) { case ONE: printf("Scoring Ones...\n"); break; case TWO: printf("Scoring Twos...\n"); break; case THREE: printf("Scoring Threes...\n"); break; case FOUR: printf("Scoring Fours...\n");...

  • How can I get started in this program for this DelivC?

    SpecificationStart with your Java program "prog340" which implements Deliverables A and B.This assignment is based on the definition of the Traveling Salesperson Problem (the TSP): Given a set of cities, you want to find the shortest route that visits every city and ends up back at the original starting city. For the purposes of this problem, every city will be directly reachable from every other city (think flying from city to city).Your goal is to use a non-genetic local search...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT