Nielit ScientistB IT 22072017
October 13, 2023DataCommunication
October 13, 2023SoftwareEngineering
Question 434

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_______.
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_______.
3


4


5


6

Question 434 Explanation:
some coaching institutes are giving B as the correct answer.
To find the cyclomatic complexity using three formulas.
1. The number of regions
2. Predicate(P) + 1 [ Predicate divides minimum 2 or more ]
3. EV+2
According to given question, we can use Predicate(P) + 1
while (first <= last) → P1
{
if (array[middle] < search) → P2
first = middle + 1;
else if (array[middle] == search) → P3
found = TRUE;
else
last = middle – 1;
middle = (first + last)/2;
}
if (first < last) not Present = TRUE; → P4
To find the cyclomatic complexity using three formulas.
1. The number of regions
2. Predicate(P) + 1 [ Predicate divides minimum 2 or more ]
3. EV+2
According to given question, we can use Predicate(P) + 1
while (first <= last) → P1
{
if (array[middle] < search) → P2
first = middle + 1;
else if (array[middle] == search) → P3
found = TRUE;
else
last = middle – 1;
middle = (first + last)/2;
}
if (first < last) not Present = TRUE; → P4
→ P+1 = 4+1 = 5
Correct Answer: C
Question 434 Explanation:
some coaching institutes are giving B as the correct answer.
To find the cyclomatic complexity using three formulas.
1. The number of regions
2. Predicate(P) + 1 [ Predicate divides minimum 2 or more ]
3. EV+2
According to given question, we can use Predicate(P) + 1
while (first <= last) → P1
{
if (array[middle] < search) → P2
first = middle + 1;
else if (array[middle] == search) → P3
found = TRUE;
else
last = middle – 1;
middle = (first + last)/2;
}
if (first < last) not Present = TRUE; → P4
To find the cyclomatic complexity using three formulas.
1. The number of regions
2. Predicate(P) + 1 [ Predicate divides minimum 2 or more ]
3. EV+2
According to given question, we can use Predicate(P) + 1
while (first <= last) → P1
{
if (array[middle] < search) → P2
first = middle + 1;
else if (array[middle] == search) → P3
found = TRUE;
else
last = middle – 1;
middle = (first + last)/2;
}
if (first < last) not Present = TRUE; → P4
→ P+1 = 4+1 = 5
Subscribe
Login
0 Comments