Question: MATLAB ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !

MATLAB !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(Tree Search) In this problem, you will complete the depth-first tree search algorithm
discussed in the lecture. The tres will be given by an adjacency matrix, where you can
assume the root node is node 1. The data will be a separate vector. You will need to
both lind the node value where the data is found as well as truck a history of all nodes
visited.
tree_search Function:
Input variables:
an adjacency matrix for a tree (root node is 1)
a vector of dala
a scalar value for which you are searching
Output variables:
a sealar representing node where the value was found (-1 if not found)
a vector representing all nodes traversed in your depth-first search
tree_search_inner Function:
(Simply put this function in the same file as the one above.)
Imput variables:
an adjacency matrix for a tree (root node is 1)
a vector of data
a scalar value for which you are searching
a scalar representing which node you are currently searching from
Output variables:
a scalar representing index where the value was found (-1 if not found)
a vector representing all indices that you indexed into the data vector
during the search
A possible sample case is:
MATLAB ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!