GateAI
Software Testing

GATE CSE 2011 · Q47

MCQ2 marksMedium

Time

The following is the comment written for a C function./* This function computes the roots of a quadratic equation a.x^2 + b.x + c = 0. The function stores two real roots in *root1 and *root2 and returns the status of validity of roots. It handles four different kinds of cases. (i) When coefficient a is zero irrespective of discriminant (ii) When discriminant is positive (iii) When discriminant is zero (iv) When discriminant is negative. Only in case (ii) and (iii), the stored roots are valid. Otherwise 0 is stored in the roots. The function returns 0 when the roots are valid and -1 otherwise. The function also ensures root1 >= root2. int get_QuadRoots(float a, float b, float c, float *root1, float *root2); */A software test engineer is assigned the job of doing black box testing. He comes up with the following test cases, many of which are redundant. Which one of the following options provide the set of non-redundant tests using equivalence class partitioning approach from input perspective for black box testing?

GATE CSE 2011 Q47 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) T2, T4, T5, T6

Software Testing

Equivalence class partitioning divides the input domain into partitions of equivalent data from which test cases can be derived. A non-redundant test suite selects exactly one representative test case from each equivalence class.

From the function specification, the four distinct equivalence classes based on inputs are:

  1. Class 1 (Case i): Coefficient a=0a = 0 (linear equation or invalid quadratic).

  2. Class 2 (Case ii): Discriminant D=b2−4ac>0D = b^2 - 4ac > 0 (two distinct real roots).

  3. Class 3 (Case iii): Discriminant D=b2−4ac=0D = b^2 - 4ac = 0 (two equal real roots).

  4. Class 4 (Case iv): Discriminant D=b2−4ac<0D = b^2 - 4ac < 0 (complex roots).

Now evaluate each provided test case:

  • T1: a=0.0,b=0.0,c=7.0  ⟹  a=0a = 0.0, b = 0.0, c = 7.0 \implies a = 0 (Class 1)

  • T2: a=0.0,b=1.0,c=3.0  ⟹  a=0a = 0.0, b = 1.0, c = 3.0 \implies a = 0 (Class 1)

  • T3: a=1.0,b=2.0,c=1.0  ⟹  D=22−4(1)(1)=0a = 1.0, b = 2.0, c = 1.0 \implies D = 2^2 - 4(1)(1) = 0 (Class 3)

  • T4: a=4.0,b=−12.0,c=9.0  ⟹  D=(−12)2−4(4)(9)=144−144=0a = 4.0, b = -12.0, c = 9.0 \implies D = (-12)^2 - 4(4)(9) = 144 - 144 = 0 (Class 3)

  • T5: a=1.0,b=−2.0,c=−3.0  ⟹  D=(−2)2−4(1)(−3)=4+12=16>0a = 1.0, b = -2.0, c = -3.0 \implies D = (-2)^2 - 4(1)(-3) = 4 + 12 = 16 > 0 (Class 2)

  • T6: a=1.0,b=1.0,c=4.0  ⟹  D=12−4(1)(4)=1−16=−15<0a = 1.0, b = 1.0, c = 4.0 \implies D = 1^2 - 4(1)(4) = 1 - 16 = -15 < 0 (Class 4)

To cover all four equivalence classes without redundancy, we must pick one test case from {T1,T2}\{T1, T2\}, one from {T3,T4}\{T3, T4\}, T5T5, and T6T6.

Among the options, (C) T2, T4, T5, T6 selects exactly one test case from each of the four equivalence classes.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Software Testing previous year question is Q47 of the GATE CSE 2011 paper. Find more GATE CSE PYQs on Software Testing in Software Engineering, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 1 related Software Testing PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Software Testing in GATE CSE

GATE CSE 2011 Q47 is the only Software Testing question in the GATE CSE papers so far.

How GATE tests Software Testing

More from GATE CSE 2011

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2011 · Q47 · MCQ

The following is the comment written for a C function. /* This function computes the roots of a quadratic equation a.x2 + b.x + c = 0. The function stores two real roots in *root1 and *root2 and returns the status of validity of roots. It handles four different kinds of cases. (i) When coefficient a is zero irrespective of discriminant (ii) When discriminant is positive (iii) When discriminant is zero (iv) When discriminant is negative. Only in case (ii) and (iii), the stored roots are valid. Otherwise 0 is stored in the roots. The function returns 0 when the roots are valid and -1 otherwise. The function also ensures root1 >= root2. int getQuadRoots(float a, float b, float c, float *root1, float *root2); */ A software test engineer is assigned the job of doing black box testing. He comes up with the following test cases, many of which are redundant. Which one of the following options provide the set of non-redundant tests using equivalence class partitioning approach from input perspective for black box testing?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.