Answered step by step
Verified Expert Solution
Link Copied!
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:

image text in transcribed

(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 input

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students explore these related Databases questions