The total number of element comparisons made in Non-DC=?

Algorithm Non_DC(A,n,max,min)
{
    max<-min<-A[1];
    for i<-2 to n 
    {
        if(A[i]>max)
        {
            max<-A[i];
        }
        if(A[i]<min)
        {
            min<-A[i];
        }
    }
}

Let us assume a best case:
What’ll be the best case?
Let us assume a worst case:
What’s the worst case?

1 Like

It isn’t helpful to ask us to answer questions without providing more context.

What do you think the answer is? Why do you think that is the answer?

1 Like