use octave or MATLAB as programs to code. do not use disp ornum2str. also, do not use break or continue statements.

Yes you can use MathLab.

4. 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 aan Adjacency using the command aanAdjacency – load(‘-ascii’, achFileName Adjacency); . 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 = load(‘-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 mode, 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 • 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: November 25, 2019 7 of 8 MAT 2010L: Lab Assignment 14 Enter filenase for adjacency matrix adjacency.txt Enter tiles for data vector dat Enter an integer to search for: 3.5 Invalid entry 31.5 Enter an integer to search for: 31 Node 11 Entered Node 1: About ‘to recurse on child node 2 Node 21 Entered Node 21 About to recurse on child node 5 Enter fllanna ter dj noney matrid cancytat Enter Plan for data vector: datatxt Enter an integer to search for: 31.5 Invalid entry 31.5 Finter an integer to mearch for: 31 Node 1 Entered Node 1 About to recurse anche node 2 Node 21 Entered Node 2 About to recurse on child node 5 Node 5: Fatared Node 5: Lanving with hFound 0And NodaFound – Node 2: About to recree on child node 6 Noda 6: Entered Node 6: Leaving with Found 0And nodaFoundat Node 2: Leaving with bFound – 0 and nNodeFoundat – Node 1 About to recurse on child sode 3 Node 31 Entered Node 3: About to recurse on child boda 7 Node 7: Entered Node 71 Leaving with Found – 1 and nNodeFoundat – Node 3: Lenving with Found – 1 and modeFoundat Node 1: Lenving with Found – 1 and nNodeFoundat 31 was found at node 7 – 1 Enter filename for adjacency matrix adjacency.txt Enter filename for data vector: date. Enter an integer to search for: 3 Node 1 Entered Node 1: About to recurse on child node 2 Node 2: Entered Node 2: About to recurse on child node 5 Node 5: Entered Node 5: Leaving with bFound – O and Nede Foundat- Node 2: About to recurse on child node 6 Node 6: Entered Node 6: Leaving with bound – 0 and nodeFoundata Node 2: Leaving with bFound – and nodeFound.At Node 1 About to recurso on child bode 3 Node 3: Entered Node 3 About to recurse on child node Node 7 Entered Node 7: Leaving with bound – and node Foundat Node 3: Leaving with bound and NodeFoundat- Node 1: About to recurge on child node Node 4: Entered Node 4 About to recurse on child node Node 8 Entered Mode B: Leaving with bound – and nodeFoundat Node 4 About to recurse on child moda 9 1 Enter filename for adjacency matrix: adjacency Enter filename for data vector: data.txt Enter an integer to search for: 3 Node 1: Entered Node 1: About to recurse on child node 2 Node 2: Entered Node 2: About to recurse on child node 5 Node 5: Entered Node 5: Leaving with bFound – 0 and nNodeFounda Node 2: About to recurge on child node 6 Node 6: Entered Node 6: Leaving with bFound and nNodeFoundat Node 2: Leaving with bFound – 0 and nNodeFoundAt Node 1: About to recurse on child node 3 Node 3: Entered Node 3: About to recurse on child node Node 7: Entered Node 7: Leaving with bFound = 0 and nNodeFoundat Node 3: Leaving with bFound = 0 and nNode FoundAt Node 1: About to recurse on child node 4 Node 4: Entered Node 4: About to recurse on child node 8 Node 8: Entered Node 8: Leaving with bFound = 0 and nNodeFoundat Node 4: About to recurse on child node 9 Node 9: Entered Node 9: Leaving with bound and nNodeFoundat Node 4: About to recurse on child node 10 Node 10: Entered Node 10: Leaving with bound and nNodeFoundat Node 4: Leaving with bFound and nNodeFoundat Node 1: Leaving with bFound .0 and nNodeFo 3 was not found Show transcribed image text 4. 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 aan Adjacency using the command aanAdjacency – load(‘-ascii’, achFileName Adjacency); . 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 = load(‘-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 mode, 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

• 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: November 25, 2019 7 of 8 MAT 2010L: Lab Assignment 14 Enter filenase for adjacency matrix adjacency.txt Enter tiles for data vector dat Enter an integer to search for: 3.5 Invalid entry 31.5 Enter an integer to search for: 31 Node 11 Entered Node 1: About ‘to recurse on child node 2 Node 21 Entered Node 21 About to recurse on child node 5

Enter fllanna ter dj noney matrid cancytat Enter Plan for data vector: datatxt Enter an integer to search for: 31.5 Invalid entry 31.5 Finter an integer to mearch for: 31 Node 1 Entered Node 1 About to recurse anche node 2 Node 21 Entered Node 2 About to recurse on child node 5 Node 5: Fatared Node 5: Lanving with hFound 0And NodaFound – Node 2: About to recree on child node 6 Noda 6: Entered Node 6: Leaving with Found 0And nodaFoundat Node 2: Leaving with bFound – 0 and nNodeFoundat – Node 1 About to recurse on child sode 3 Node 31 Entered Node 3: About to recurse on child boda 7 Node 7: Entered Node 71 Leaving with Found – 1 and nNodeFoundat – Node 3: Lenving with Found – 1 and modeFoundat Node 1: Lenving with Found – 1 and nNodeFoundat 31 was found at node 7 – 1 Enter filename for adjacency matrix adjacency.txt Enter filename for data vector: date. Enter an integer to search for: 3 Node 1 Entered Node 1: About to recurse on child node 2 Node 2: Entered Node 2: About to recurse on child node 5 Node 5: Entered Node 5: Leaving with bFound – O and Nede Foundat- Node 2: About to recurse on child node 6 Node 6: Entered Node 6: Leaving with bound – 0 and nodeFoundata Node 2: Leaving with bFound – and nodeFound.At Node 1 About to recurso on child bode 3 Node 3: Entered Node 3 About to recurse on child node Node 7 Entered Node 7: Leaving with bound – and node Foundat Node 3: Leaving with bound and NodeFoundat- Node 1: About to recurge on child node Node 4: Entered Node 4 About to recurse on child node Node 8 Entered Mode B: Leaving with bound – and nodeFoundat Node 4 About to recurse on child moda 9 1

Enter filename for adjacency matrix: adjacency Enter filename for data vector: data.txt Enter an integer to search for: 3 Node 1: Entered Node 1: About to recurse on child node 2 Node 2: Entered Node 2: About to recurse on child node 5 Node 5: Entered Node 5: Leaving with bFound – 0 and nNodeFounda Node 2: About to recurge on child node 6 Node 6: Entered Node 6: Leaving with bFound and nNodeFoundat Node 2: Leaving with bFound – 0 and nNodeFoundAt Node 1: About to recurse on child node 3 Node 3: Entered Node 3: About to recurse on child node Node 7: Entered Node 7: Leaving with bFound = 0 and nNodeFoundat Node 3: Leaving with bFound = 0 and nNode FoundAt Node 1: About to recurse on child node 4 Node 4: Entered Node 4: About to recurse on child node 8 Node 8: Entered Node 8: Leaving with bFound = 0 and nNodeFoundat Node 4: About to recurse on child node 9 Node 9: Entered Node 9: Leaving with bound and nNodeFoundat Node 4: About to recurse on child node 10 Node 10: Entered Node 10: Leaving with bound and nNodeFoundat Node 4: Leaving with bFound and nNodeFoundat Node 1: Leaving with bFound .0 and nNodeFo 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. Yes…