function res = goo(x,y) i = 1; j=1; res=[ ]; while i<=length(x) & j<=length(y) a
ID: 3740110 • Letter: F
Question
function res = goo(x,y)
i = 1; j=1; res=[ ];
while i<=length(x) & j<=length(y)
a = x(i); b=y(j);
if a<b
res=[res, a];
i = i+1;
elseif a>b
res=[res, b];
j=j+1;
else
res=[res, a];
i = i+j; j=j+1;
end
end
Consider the function goo. Answer the following:
(a) goo([1,2,3,4], [2,3,5]) returns
(b) goo([1,2,3,4], [1,2,3,4]) returns
(c) goo([1,2,3,4], [ ]) returns
(d) what is the runtime of goo?
(e) explain what goo does?
================
Data structure and Algorithm problem.
Read carefully and Only full answers will get positive rated. Thank you.
Show necessary steps
Explanation / Answer
(a) goo([1,2,3,4], [2,3,5]) returns
(b) goo([1,2,3,4], [1,2,3,4]) returns
1 2 3 4
(c) goo([1,2,3,4], [ ]) returns
[ ]
(d) what is the runtime of goo?
O(n)
(e) explain what goo does?
It compates each element of the list and stores the minimum value into result list
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.