Q. The following function computes the maximum value contained in an integer array p[] of size n (n >= 1)

Code:
int max(int *p, int n)
{
    int a=0, b=n-1;
    while (__________)
    {
        if (p[a] <= p[b])
        {
            a = a+1;
        }
        else
        {
            b = b-1;
        }
    }
    return p[a];
}
  • (A) a != n
  • (B) b != 0
  • (C) b > (a + 1)
  • (D) b != a
πŸ’¬ Discuss
βœ… Correct Answer: (D) b != a

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
260
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
95%
Success Rate