Gate CS-2015-1 Question Paper With Solutions

Q. 52 Consider the following C program segment.

while (first <= last)
{
   if (array [middle] < search)
      first = middle +1;
   else if (array [middle] == search)
      found = True;
   else last = middle – 1;
   middle = (first + last)/2;
}
if (first < last) not Present = True;

The cyclomatic complexity of the program segment is ______.

(A) 3

(B) 4

(C) 5

(D) 6

Answer: (C)

Explanation:

Gate CS-2015-1 Question Paper With Solutions Gate CS-2015-1 Question Paper With Solutions

Learn More:   Gate EE-2013 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here