Question

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.

Test Caseabcroot1root2Return Value
T10.00.07.00.00.0-1
T20.01.03.00.00.0-1
T31.02.01.0-1.0-1.00
T44.0-12.09.01.51.50
T51.0-2.0-3.03.0-1.00
T61.01.04.00.00.0-1

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?

Choose one option
Official answer and solution
Official answer
C
From
Official GATE 2011 answer key

Solution

Partition the input domain into non-overlapping equivalence classes and select exactly one test per class.

  1. The function specifies 4 disjoint input equivalence classes based on quadratic coefficients and the discriminant D=b2−4acD = b^2 - 4ac:
  • Class 1: a=0a = 0 (linear equation / invalid quadratic)
  • Class 2: a≠0a \ne 0 and D>0D > 0 (two distinct real roots)
  • Class 3: a≠0a \ne 0 and D=0D = 0 (two equal real roots)
  • Class 4: a≠0a \ne 0 and D<0D < 0 (complex roots / invalid)
  1. Categorize the test cases:
  • T1: a=0.0  ⟹  a = 0.0 \implies Class 1
  • T2: a=0.0  ⟹  a = 0.0 \implies Class 1
  • T3: a=1.0,D=4−4=0  ⟹  a = 1.0, D = 4 - 4 = 0 \implies Class 3
  • T4: a=4.0,D=144−144=0  ⟹  a = 4.0, D = 144 - 144 = 0 \implies Class 3
  • T5: a=1.0,D=4−4(1)(−3)=16>0  ⟹  a = 1.0, D = 4 - 4(1)(-3) = 16 > 0 \implies Class 2
  • T6: a=1.0,D=1−16=−15<0  ⟹  a = 1.0, D = 1 - 16 = -15 < 0 \implies Class 4
  1. In equivalence class partitioning, testing more than one test case from the same class is redundant. A minimal, non-redundant suite must select one test case from each of the 4 classes.
  1. Option C selects {T2,T4,T5,T6}\{T2, T4, T5, T6\}, containing exactly one test from each class: T2 (Class 1), T5 (Class 2), T4 (Class 3), and T6 (Class 4).
Final answer

C

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2011 Computer Science and Information Technology (CS)
Question
47 of 65, printed as CS Q.47
Section
Computer Science and Information Technology

This question is from a part of the syllabus that is no longer in GATE CS. It is kept because it was in the paper.

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.