Question: Below is a Python function definition for a linear search of a list Ist for element. It returns the first index at which element can

Below is a Python function definition for a linear search of a list Ist for element. It returns the first index at which element can be found in the list (or None) if element is not in the list. def linearsearch(lst, element): for item in 1st: if element .. item : return i else: return None Write a similar MATLAB function linearSearch.m. Your MATLAB function should take as parameters an unsorted list of non-negative integers, and an integer value, and returns the index where that value is first located in the list. (No argument testing is required.) Unlike the Python code which returns None if the value is not in the array, your MATLAB function should return the value -1 if the value is not found. Answer function [y]=linearSearch(1st,element) 1-1 3 sum-0 4 for x-1:length(lst)-1 if Ist(x)-item sum else i-i+1 end 10 end 11 y=sum 12 end Check
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
