Hej mam problem z napisaniem złożoności czasowej do podanego algorytmu. Mógłbym ktoś pomóc :).
function result=palindrome(TAB)
K=length(TAB)
I=floor(K/2)+1
L=1
J=1
result='JEDNA Z POŁÓWEK TABLICY NIE JEST PALINDROMEM.'
if modulo(K,2) == 1 then
I = I + 1
end
firstPart = slice(TAB,L,floor(K/2))
secondPart = slice(TAB,I,K)
if checkIsPalindrome(firstPart) == 1 then
if checkIsPalindrome(secondPart) == 1 then
result='OBIE POŁÓWKI SĄ PALINDROMAMI!'
end
end
endfunction
function TAB=slice(TAB, startindex, endindex)
TAB = TAB(startindex:endindex)
endfunction
function result=checkIsPalindrome(TAB)
result = 0
i = 1;
n = length(TAB)
while i*2<n do
if TAB(i) == TAB((n-i)+1) then
i = i + 1
else
return;
end
end
result = 1
endfunction