Algorithm Non_DC(A,n,max,min)
{
max<-min<-A[1 ];
for i<-2 to n
{
if(A[i]>max)
{
max<-A[i];
}
else if (A[i]<min)
{
min<-A[i];
}
}
}
It’s said that the best case of this algorithm is if array is in increasing order. Why?
It’s said that the worst case of this algorithm is if array is in decreasing order. Why?
I know this is probably a dumb question, but I am failing to understand this much as well.