Computer Science homework Assignment

Computer Science homework Assignment

HINTS for E.C. Program 4 Data Structure: You are required to use a dynamic 2D array (array of arrays) or a vector of vectors. Declare the structure BEFORE the loop, allocate and fill in the loop. Clear it out in the loop at the end. Vectors are described on page 557 of the Gaddis book. 2D arrays are described at https://gsamaras.wordpress.com/code/dynamic-2d-array-in-c/ If you do 2D arrays, the heading for the function will look like void readGraph(ifstream & infile, int ** & graph, int & size);

File I/O: Comment out the requests for filenames until your last run and before you turn it in. Change the “filename” to infileName or outfileName as appropriate before turning it in. void openFiles(ifstream & infile, ofstream & outfile)

{

char infileName[40];

char outfileName[40];

//cout << “Enter name of input file:”;

//cin >> infileName;

infile.open(“connected2D.dat”);

//cout << “Enter name of output file:”;

//cin >> outfileName;

outfile.open(“out.dat”);

}

Early exit loops: The function that check if a graph has an Euler Circuit has an outer loop with a Boolean flag that is initialized to true. The function that finds an Euler Circuit has a do-while loop for the outer loop (stop when the next vertex is the same as the original vertex). There is an inner while loop that stops when you find an adjacent vertex. The function that determines if the graph has any edges has two while loops that use a Boolean flag that is initialized to true. Removing (cutting) and edge: Don’t forget to remove both (u, v) and (v, u) since the graphs are undirected.

dynamic 2D array in C++

Calculate the price

Pages (550 words)
Approximate price: -