CS FundamentalsVery hardGATE CS · product placement
A function is a straight sequence of three independent if-else statements, with no loops. What are (total entry-to-exit paths, cyclomatic complexity, minimum tests for 100% branch coverage)?
- A. (8, 4, 2)
- B. (8, 4, 4)
- C. (6, 3, 2)
- D. (8, 3, 8)
Correct answer: A. (8, 4, 2)
Independent choices multiply: 2^3 = 8 paths. V(G) = 3 decisions + 1 = 4 basis paths. Two tests suffice for branches: one taking every 'if' side and one taking every 'else' side. Paths grow exponentially, branches only linearly.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- How many definition-use (def-use) pairs does variable x have in this fragment (a p-use in a condition counts as a use)? python x =…
- For the function below, the tests (age = 30, member = True) and (age = 10, member = False) already give 100% statement and branch…
- McCabe's V(G) = E - N + 2 for one function comes from the cyclomatic number of a strongly connected graph, E - N + P. Where does the '+2'…
- A loan is approved if (salary ≥ ₹50,000 AND credit history is good) OR a guarantor is provided. Using a limited-entry decision table with…
- An ATM state machine: inserting a card leads to '1st try'. A correct PIN in any try state leads to 'Access'; a wrong PIN moves 1st → 2nd →…
- A price field accepts amounts from ₹0.01 to ₹999.99, with exactly two decimal places. Which pair of values are the invalid boundary values…