(Solved) : Use Octave Matlab Programs Code Use Disp Num2str Also Use Break Continue Statements 4 Prob Q42760961 . . .

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

4. In this problem we will implement the depth first search of atree. Write a program that calls a function get data which should •prompt the user for the name of a data file containing a tree’sadjacency matrix and store it in a string variableachFileNameAdjacency • load the adjacency matrix from the specifiedfile into the matrix aanAdjacency using the command aanAdjacency =load( ‘-ascii’, achFileNameAdjacency ); • prompt the user for thename of a data file containing a tree’s data vector and store it ina string variable achFileNameVector • load the data vector from thespecified file into the vector anData using the command anData =load( ‘-ascii’, achFileNameVector ); • keep prompting the user andgiving error messages until an integer (search value) is entered •return the adjacency matrix, data vector, and integer value Themain program should then call the function depth first search which(as discussed in class) should • take in the number of nodes in thegraph, the adjacency matrix, the data vector, the number of thecurrent node, and the search value • upon entry, print a debugmessage displaying the number of the current node • call itselfrecursively as needed to implement a depth first search for thespecified integer • immediately before making the recursive call,print a debug message displaying the number of the node to berecursed upon • before exiting the function, print a debug messagedisplaying the number of the current node and the values of the twooutput variables • return a Boolean variable indicating whether ornot the search value was found and a variable giving the nodenumber 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.txtEnter filename for data vector: data.txt Enter an integer to searchfor: 31.5 Invalid entry 31.5 Enter an integer to search for: 31Node 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: EnteredNode 5: Leaving with bFound = 0 and nNodeFoundAt = -1 Node 2: Aboutto recurse on child node 6 Node 6: Entered Node 6: Leaving withbFound = 0 and nNodeFoundAt = -1 Node 2: Leaving with bFound = 0and nNodeFoundAt = -1 Node 1: About to recurse on child node 3 Node3: Entered Node 3: About to recurse on child node 7 Node 7: EnteredNode 7: Leaving with bFound = 1 and nNodeFoundAt = 7 Node 3:Leaving with bFound = 1 and nNodeFoundAt = 7 Node 1: Leaving withbFound = 1 and nNodeFoundAt = 7 31 was found at node 7 Enterfilename for adjacency matrix: adjacency.txt Enter filename fordata vector: data.txt Enter an integer to search for: 3 Node 1:Entered Node 1: About to recurse on child node 2 Node 2: EnteredNode 2: About to recurse on child node 5 Node 5: Entered Node 5:Leaving with bFound = 0 and nNodeFoundAt = -1 Node 2: About torecurse on child node 6 Node 6: Entered Node 6: Leaving with bFound= 0 and nNodeFoundAt = -1 Node 2: Leaving with bFound = 0 andnNodeFoundAt = -1 Node 1: About to recurse on child node 3 Node 3:Entered Node 3: About to recurse on child node 7 Node 7: EnteredNode 7: Leaving with bFound = 0 and nNodeFoundAt = -1 Node 3:Leaving with bFound = 0 and nNodeFoundAt = -1 Node 1: About torecurse on child node 4 Node 4: Entered Node 4: About to recurse onchild node 8 Node 8: Entered Node 8: Leaving with bFound = 0 andnNodeFoundAt = -1 Node 4: About to recurse on child node 9 Node 9:Entered Node 9: Leaving with bFound = 0 and nNodeFoundAt = -1 Node4: About to recurse on child node 10 Node 10: Entered Node 10:Leaving with bFound = 0 and nNodeFoundAt = -1 Node 4: Leaving withbFound = 0 and nNodeFoundAt = -1 Node 1: Leaving with bFound = 0and nNodeFoundAt = -1 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. 4. …

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?