Solved
Complexity in algorithms and succesive division
Posted on 2000-01-31
I have an algorithm of a funtion called sum:
function sum(a,i,j)
z=0
for k=i to j do
{z=z+a[k]}
return(z)
Now i have this algorithms that i got to find what they do and what's their complexity[Big OH Notation.(I'm learning all this by reading.)
Here are the algorithms:
(a.)
m=0
for i=1 to n do
for j=i to n do
{x=sum(a,i,j)
if m<x then m=x}
(b.)
m=0
for i=1 to n do
for j=1 to n do
{x=sum(a,1,n)
if m<x then m=x}
(c.)
m=0
for i=1 to n/4 do
for j=3n/4 to n do
{x=sum(a,i,j)
if m<x then m=x}
(d.)
m=0
for i=1 to n/4 do
for j=3n/4 to n do
{x=sum(a,1,n/2)
if m<x then m=x}
I will appreciate your help in understanding this and some info where i can find more about complexity.