Use octave or MATLAB as programs to code.
Do not use disp or num2str.
Also, do not use break or continue statements.
In this problem we will implement the depth first search of a tree. Write a program that calls a function get data which should prompt the user for the name of a data file containing a tree’s adjacency matrix and store it in a string variable achFileNameAdjacency load the adjacency matrix from the specified file into the matrix aanAdjacency using the command = load’-ascii’, achFileNameAdjacency ); aanAdjacency prompt the user for the name of a data file containing a tree’s data vector and store it in a string variable achFileNameVector load the data vector from the specified file into the vector anData using the command anData 1oad ( ‘-ascii’, achFileNameVector ); keep prompting the user and giving error messages until an integer (search value) is entered return the adjacency matrix, data vector, and integer value The main program should then call the function depth first search which (as discussed in class) should take in the number of nodes in the graph, the adjacency matrix, the data vector, the number of the current node, and the search value upon entry, print a debug message displaying the number of the current node call itself recursively as needed to implement a depth first search for the specified integer immediately before making the recursive call, print a debug message displaying the number of the node to be recursed upon before exiting the function, print a debug message displaying the number of the current node and the values of the two output variables return a Boolean variable indicating whether or not the search value was found and a variable giving the node number at which the search value was found (if it was; otherwise -1 The main program should then print the results of the search. Sample output: Enter filename for adjacency matrix: adjacency.txt Enter filename for data vector: data.txt Enter an int eger to search for: 31.5 Invalid entry 31.5 Enter an integer to search for: 31 Node 1: Entered 1: About to recurse on child no de Node 2 Node 2: Entered Node 2: About to recurse on child node Node 5: Entered 5: Leaving with bFound = 0 and nN od eF o undAt = -1 2: About to recurse on child no de 6 Node Node Node 6: Entered 6: Leaving with bFound = 0 and nNodeFoundAt = -1 2: Leaving with bFound = 0 and nNodeFoundAt -1 1: About to recurse on child no de 3 Node Node Node Node 3: Entered 3: About to recurse on child no de Node 7 Node 7: Entered 7: Leaving with bFound = 1 and nNodeFoundAt = 7 Node Node 3: Leaving with bFound = 1 and nNodeFoundAt = 7 1: Leaving with bFound = 1 and nN od eFoundAt = Node 7 31 was found at node 7 Enter filename for adjacency matrix: adjacency.txt Enter filename for data vector: data.txt Enter an int eger to search for: 3 Node 1: Entered Node 1: About to recurse on child node 2 Node 2: Entered 2: About to recurse on child no de Node 5: Entered 5: Leaving with bFound = 0 and nNodeFoundAt = -1 2: About to recurse on child no de Node Node Node 6 Node 6: Entered 6: Leaving with bFound = 0 and nNod eF o undAt = -1 Node Node 2: Leaving with bFound = 0 and nNodeFoundAt = -1 1: About to recurse on child no de 3 Node Node 3: Entered 3: About to recurse on child no de Node 7 Node 7: Entered 7: Leaving with bFound = 0 and nNod eFoun dAt = -1 Node Node 3: Leaving with bFound = 0 and nNodeFoundAt = -1 Node 1: About to recurse on child node 4 Node 4: Entered Node 4: About to recurse on child node 8 Node 8: Entered 8: Leaving with bFound = 0 and nNodeFoun dAt = -1 4: About to recurse on child no de Node Node Node 9: Entered Node 9: Leaving with bFound = 0 and nN od eF oundAt = -1 4: About to recurse on child no de 10 Node Node 10: Ent ered Node 10: Leaving with bFound = 0 and nNodeFoundAt = -1 4: Leaving with bFound = 0 and nNod eF o un dAt = -1 1: Leaving with bFound = 0 and nNod eFoundAt = -1 Node Node 3 was not found Show transcribed image text In this problem we will implement the depth first search of a tree. Write a program that calls a function get data which should prompt the user for the name of a data file containing a tree’s adjacency matrix and store it in a string variable achFileNameAdjacency load the adjacency matrix from the specified file into the matrix aanAdjacency using the command = load’-ascii’, achFileNameAdjacency ); aanAdjacency prompt the user for the name of a data file containing a tree’s data vector and store it in a string variable achFileNameVector load the data vector from the specified file into the vector anData using the command anData 1oad ( ‘-ascii’, achFileNameVector ); keep prompting the user and giving error messages until an integer (search value) is entered return the adjacency matrix, data vector, and integer value The main program should then call the function depth first search which (as discussed in class) should take in the number of nodes in the graph, the adjacency matrix, the data vector, the number of the current node, and the search value upon entry, print a debug message displaying the number of the current node call itself recursively as needed to implement a depth first search for the specified integer immediately before making the recursive call, print a debug message displaying the number of the node to be recursed upon before exiting the function, print a debug message displaying the number of the current node and the values of the two output variables return a Boolean variable indicating whether or not the search value was found and a variable giving the node number at which the search value was found (if it was; otherwise -1 The main program should then print the results of the search. Sample output:
Enter filename for adjacency matrix: adjacency.txt Enter filename for data vector: data.txt Enter an int eger to search for: 31.5 Invalid entry 31.5 Enter an integer to search for: 31 Node 1: Entered 1: About to recurse on child no de Node 2 Node 2: Entered Node 2: About to recurse on child node Node 5: Entered 5: Leaving with bFound = 0 and nN od eF o undAt = -1 2: About to recurse on child no de 6 Node Node Node 6: Entered 6: Leaving with bFound = 0 and nNodeFoundAt = -1 2: Leaving with bFound = 0 and nNodeFoundAt -1 1: About to recurse on child no de 3 Node Node Node Node 3: Entered 3: About to recurse on child no de Node 7 Node 7: Entered 7: Leaving with bFound = 1 and nNodeFoundAt = 7 Node Node 3: Leaving with bFound = 1 and nNodeFoundAt = 7 1: Leaving with bFound = 1 and nN od eFoundAt = Node 7 31 was found at node 7 Enter filename for adjacency matrix: adjacency.txt Enter filename for data vector: data.txt Enter an int eger to search for: 3 Node 1: Entered Node 1: About to recurse on child node 2 Node 2: Entered 2: About to recurse on child no de Node 5: Entered 5: Leaving with bFound = 0 and nNodeFoundAt = -1 2: About to recurse on child no de Node Node Node 6 Node 6: Entered 6: Leaving with bFound = 0 and nNod eF o undAt = -1 Node Node 2: Leaving with bFound = 0 and nNodeFoundAt = -1 1: About to recurse on child no de 3 Node Node 3: Entered 3: About to recurse on child no de Node 7 Node 7: Entered 7: Leaving with bFound = 0 and nNod eFoun dAt = -1 Node Node 3: Leaving with bFound = 0 and nNodeFoundAt = -1 Node 1: About to recurse on child node 4 Node 4: Entered Node 4: About to recurse on child node 8 Node 8: Entered 8: Leaving with bFound = 0 and nNodeFoun dAt = -1 4: About to recurse on child no de Node Node Node 9: Entered Node 9: Leaving with bFound = 0 and nN od eF oundAt = -1 4: About to recurse on child no de 10 Node Node 10: Ent ered Node 10: Leaving with bFound = 0 and nNodeFoundAt = -1 4: Leaving with bFound = 0 and nNod eF o un dAt = -1 1: Leaving with bFound = 0 and nNod eFoundAt = -1 Node Node 3 was not found
Expert Answer
Answer to Use octave or MATLAB as programs to code. Do not use disp or num2str. Also, do not use break or continue statements. …