Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using Matlab to solve following question: (2) Write the function find elt which takes as an input a vector v and an element x. The
Using Matlab to solve following question:
(2) Write the function find elt which takes as an input a vector v and an element x. The output is 0 if the element x does not occur in v, 1 if the element x does occur in v. Below is the algorithm you should implement Default output is 0 for elt in v if elt-ex, make output 1, break, end end Checking if elt-=x counts as one step. Setting the output value also counts as one step. a) How many steps does it take for the input of v-[1, 3, 2, 7, 9] and x-2? List each step in order b) What's the most number of steps it could take for length 5 input? (c) What's the most number of steps it could take for a length n input? (2) Write the function find elt which takes as an input a vector v and an element x. The output is 0 if the element x does not occur in v, 1 if the element x does occur in v. Below is the algorithm you should implement Default output is 0 for elt in v if elt-ex, make output 1, break, end end Checking if elt-=x counts as one step. Setting the output value also counts as one step. a) How many steps does it take for the input of v-[1, 3, 2, 7, 9] and x-2? List each step in order b) What's the most number of steps it could take for length 5 input? (c) What's the most number of steps it could take for a length n inputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started