III-i - Cse - ST Coursematerial Unit - 4
III-i - Cse - ST Coursematerial Unit - 4
III-i - Cse - ST Coursematerial Unit - 4
TIRUPATI
COURSE MATERIAL
UNIT 4
COURSE B.TECH
DEPARTMENT CSE
SEMESTER 41
Version V-5
BTECH_MEC-SEM 41
SVCE
TIRUPATI
9 PRACTICE QUIZ 46
10 ASSIGNMENTS 49
11 PART A QUESTIONS & ANSWERS (2 MARKS QUESTIONS) 49
12 PART B QUESTIONS 50
13 SUPPORTIVE ONLINE CERTIFICATION COURSES 50
14 REAL TIME APPLICATIONS 50
15 CONTENTS BEYOND THE SYLLABUS 52
16 PRESCRIBED TEXT BOOKS & REFERENCE BOOKS 52
17 MINI PROJECT SUGGESTION 52
BTECH_MEC-SEM 41
SVCE
TIRUPATI
1. Course Objectives
The objectives of this course is to
1. Fundamentals for various testing Methodologies.
2. Describe the Principles and procedures for designing test cases.
3. Provide support to debugging methods.
4. Acts as reference for software testing techniques and strategies.
2. Prerequisites
Students should have knowledge on
1. Should have mathematical knowledge
2. Should have logical thinking
3. Should have keen analytical skills
3. Syllabus
Paths, Path products and Regular expressions: Path Products & Path Expression,
Reduction Procedure, Applications, Regular Expressions & Flow Anomaly Detection.
Logic Based Testing: Overview, Decision Tables, Path Expressions, KV Charts,
Specifications.
4. Course outcomes
1. Interpret the control flow graph and identify the path products, path sums and path expressions
2. Understand the concept of Logic based testing.
3. Understand the use of decision tables in test-case design and know their
Limitations.
4. Understand and interpret KV Charts and know their limitations.
5. Learn how to transform specifications into sentences and map them into KV charts.
ST PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 P10 PO11 PO12 PSO1 PSO2
CO1 2 3 3 3 3
CO2 2 3 3 2 2 3 3
CO3 3 3 3 2 2 2 3
CO4 3 3 2 3
CO5 2 3 3 3 3
6. Lesson Plan
1|ST-UNIT-IV
BTECH_CSE-SEM 41
SVCE
TIRUPATI
Lecture No. Weeks Topics to be covered References
8. Lecture Notes
1.1 INTRODUCTION
Flow graphs are being an abstract representation of programs.
Any question about a program can be cast into an equivalent question about an appropriate
flow graph.
Most software development, testing and debugging tools use flow graphs analysis techniques.
2|ST-UNIT-IV
BTECH_CSE-SEM 41
SVCE
TIRUPATI
The name of the path or path segment that corresponds to those links is expressed naturally by
concatenating those link names.
For example, if you traverse links a,b,c and d along some path, the name for that path segment is
abcd. This path name is also called a path product. Figure 1.1 shows some examples:
Consider a pair of nodes in a graph and the set of paths between those node.
Denote that set of paths by Upper case letter such as X,Y. From Figure 1.1c, the members of the
path set can be listed as follows:
ac+abc+abbc+abbbc+abbbbc+...........
The + sign is understood to mean "or" between the two nodes of interest, paths
Any expression that consists of path names and "OR"s and which denotes a set of paths between
two nodes is called a "Path Expression.".
3|ST-UNIT-IV
BTECH_CSE-SEM 41
SVCE
TIRUPATI
The name of a path that consists of two successive path segments is conveniently expressed
by the concatenation or Path Product of the segment names.
For example, if X and Y are defined as X=abcde,Y=fghij,then the path corresponding to X
followed by Y is denoted by
XY=abcdefghij
Similarly,
YX=fghijabcde
aX=aabcde
Xa=abcdea
XaX=abcdeaabcde
If X and Y represent sets of paths or path expressions, their product represents the set of
paths that can be obtained by following every element of X by any element of Y in all
possible ways. For example,
X = abc + def + ghi
Y = uvw + z
Then,
If a link or segment name is repeated, that fact is denoted by an exponent. The exponent's value
denotes the number of repetitions:
a1 = a; a2 = aa; a3 = aaa; an = aaaa . . . n times.
Similarly, if
X = abcde
then
X1 = abcde
X2 = abcdeabcde = (abcde)2
X3 = abcdeabcdeabcde = (abcde)2abcde
= abcde(abcde)2 = (abcde)3
RULE 1: A(BC)=(AB)C=ABC
where A,B,C are path names, set of path names or path expressions.
The zeroth power of a link name, path product, or path expression is also needed for
completeness. It is denoted by the numeral "1" and denotes the "path" whose length is
zero - that is, the path that doesn't have any links.
a0 = 1
X0 = 1
4|ST-UNIT-IV
BTECH_CSE-SEM 41
SVCE
TIRUPATI
1.2.3 PATH SUMS
o The "+" sign was used to denote the fact that path names were part of the same set of
paths.
o The "PATH SUM" denotes paths in parallel between nodes.
o Links a and b in Figure 5.1a are parallel paths and are denoted by a + b. Similarly, links
c and d are parallel paths between the next two nodes and are denoted by c + d.
o The set of all paths between nodes 1 and 2 can be thought of as a set of parallel paths
and denoted by eacf+eadf+ebcf+ebdf.
o If X and Y are sets of paths that lie between the same pair of nodes, then X+Y denotes
the UNION of those set of paths. For example, in Figure 1.2:
The first set of parallel paths is denoted by X + Y + d and the second set by U + V + W
+ h + i + j. The set of all paths in this flowgraph is f(X + Y + d)g(U + V + W + h + i +
j)k
The product and sum operations are distributive, and the ordinary rules of
multiplication apply; that is
e(a+b)(c+d)f=e(ac+ad+bc+bd)f = eacf+eadf+ebcf+ebdf
If X and Y denote the same set of paths, then the union of these sets is unchanged;
consequently,
5|ST-UNIT-IV
BTECH_CSE-SEM 41
SVCE
TIRUPATI
If a set consists of paths names and a member of that set is added to it, the "new" name,
which is already in that set of names, contributes nothing and can be ignored.
For example,
if X=a+aa+abc+abcd+def then
X+a = X+aa = X+abc = X+abcd = X+def = X
It follows that any arbitrary sum of identical path expressions reduces to the same path
expression.
1.2.6 LOOPS
Loops can be understood as an infinite set of parallel paths. Say that the loop consists
of a single link b. then the set of all paths through that loop point is
b0+b1+b2+b3+b4+b5+..............
This potentially infinite sum is denoted by b* for an individual link and by X* when X
is a path expression.
The path expression for the above figure is denoted by the notation:
ab*c=ac+abc+abbc+abbbc+................
Evidently,
6|ST-UNIT-IV
BTECH_CSE-SEM 41
SVCE
TIRUPATI
It is more convenient to denote the fact that a loop cannot be taken more than a certain,
say n, number of times.
Xn = X0+X1+X2+X3+X4+X5+..................+Xn
RULES 6 - 16:
RULE 6: Xn + Xm = Xn if n>m
RULE 6: Xn + Xm = Xm if m>n
RULE 7: XnXm = Xn+m
RULE 8: XnX* = X*Xn = X*
RULE 9: XnX+ = X+Xn = X+
RULE 10: X*X+ = X+X* = X+
RULE 11: 1 + 1 = 1
RULE 12: 1X = X1 = X
Following or preceding a set of paths by a path of zero length does not change the set.
RULE 13: 1n = 1n = 1* = 1+ = 1
No matter how often you traverse a path of zero length, It is a path of zero length.
RULE 14: 1++1 = 1*=1
The null set of paths is denoted by the numeral 0. it obeys the following rules:
RULE 15: X+0=0+X=X
RULE 16: 0X=X0=0
If you block the paths of a graph for or aft by a graph that has no paths , there wont be
any paths.
o This section presents a reduction procedure for converting a flowgraph whose links are
labeled with names into a path expression that denotes the set of all entry/exit paths in
that flowgraph. The procedure is a node-by-node removal algorithm.
o The steps in Reduction Algorithm are as follows:
1. Combine all serial links by multiplying their path expressions.
2. Combine all parallel links by adding their path expressions.
3. Remove all self-loops (from any node to itself) by replacing them with a link
of the form X*, where X is the path expression of the link in that loop.
7|ST-UNIT-IV
BTECH_CSE-SEM 41
SVCE
TIRUPATI
8. Does the graph consist of a single link between the entry node and the exit
node? If yes, then the path expression for that link is a path expression for
the original flowgraph; otherwise, return to step 4.
o A flowgraph can have many equivalent path expressions between a given pair of
nodes; that is, there are many different ways to generate the set of all paths between
two nodes without affecting the content of that set.
o The appearance of the path expression depends, in general, on the order in which nodes
are removed.
(a + b)(c + d + e) = ac + ad + + ae + bc + bd + be
In the first way, we remove the self-loop and then multiply all outgoing links by Z*.
8|ST-UNIT-IV
BTECH_CSE-SEM 41
SVCE
TIRUPATI
In the second way, we split the node into two equivalent nodes, call them A and A' and
put in a link between them whose path expression is Z*. Then we remove node A'
using steps 4 and 5 to yield outgoing links whose path expressions are Z*X and Z*Y.
Let us see by applying this algorithm to the following graph where we remove several
nodes in order; that is
9|ST-UNIT-IV
BTECH_CSE-SEM 41
SVCE
TIRUPATI
10 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
11 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
Removing the loop and then node 6 result in the following expression:
a(bgjf)*b(c+gkh)d((ilhd)*imf(bjgf)*b(c+gkh)d)*(ilhd)*e
You can practice by applying the algorithm on the following flowgraphs and generate
their respective path expressions:
1.4. APPLICATIONS
o The purpose of the node removal algorithm is to present one very generalized concept-
the path expression and way of getting it.
o Every application follows this common pattern:
1. Convert the program or graph into a path expression.
2. Identify a property of interest and derive an appropriate set of "arithmetic"
rules that characterizes the property.
3. Replace the link names by the link weights for the property of interest. The
path expression has now been converted to an expression in some algebra,
such as ordinary algebra, regular expressions, or boolean algebra. This
algebraic expression summarizes the property of interest over the set of all
paths.
12 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
4. Simplify or evaluate the resulting "algebraic" expression to answer the
question you asked.
o The question is not simple. Here are some ways you could ask it:
1. What is the maximum number of different paths possible?
2. What is the fewest number of paths possible?
3. How many different paths are there really?
4. What is the average number of paths?
o Determining the actual number of different paths is an inherently difficult problem
because there could be unachievable paths resulting from correlated and dependent
predicates.
o If we know both of these numbers (maximum and minimum number of possible paths)
we have a good idea of how complete our testing is.
o Asking for "the average number of paths" is meaningless.
This arithmetic is an ordinary algebra. The weight is the number of paths in each set.
EXAMPLE:
13 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
Each link represents a single link and consequently is given a weight of "1"
to start. Lets say the outer loop will be taken exactly four times and inner
Loop Can be taken zero or three times Its path expression, with a little work,
is:
A: The flow graph should be annotated by replacing the link name with the
maximum of paths through that link (1) and also note the number of times
for looping.
B: Combine the first pair of parallel loops outside the loop and also the pair
in the outer loop.
C: Multiply the things out and remove nodes to clear the clutter.
2 X 84 X 2 = 32,768.
14 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
o Alternatively, you could have substituted a "1" for each link in the path expression and
then simplified, as follows:
a(b+c)d{e(fi)*fgj(m+l)k}*e(fi)*fgh
= 1(1 + 1)1(1(1 x 1)31 x 1 x 1(1 + 1)1)41(1 x 1)31 x 1 x 1
= 2(131 x (2))413
= 2(4 x 2) x
4
4
= 2 x 8 x 4 = 32,768
4
o Structured code can be defined in several different ways that do not involve ad-hoc
rules such as not using GOTOs.
o A structured flowgraph is one that can be reduced to a single link by successive
application of the transformations of Figure 1.7.
15 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
o The node-by-node reduction procedure can also be used as a test for structured code.
o Flow graphs that DO NOT contain one or more of the graphs shown below (Figure 1.8)
as subgraphs are structured.
16 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
A lower bound on the number of paths in a routine can be approximated for structured
flow graphs.
17 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
The values of the weights are the number of members in a set of paths.
EXAMPLE:
Applying the arithmetic to the earlier example gives us the identical steps
unitl step 3 (C) as below:
18 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
If you observe the original graph, it takes at least two paths to cover and that
it can be done in two paths.
If you have fewer paths in your test plan than this minimum you probably
haven't covered. It's another check.
This question can be answered under suitable assumptions, primarily that all probabilities
involved are independent, which is to say that all decisions are independent and
uncorrelated.
We use the same algorithm as before : node-by-node removal of uninteresting nodes.
Weights, Notations and Arithmetic:
Probabilities can come into the act only at decisions (including decisions associated
with loops).
Annotate each outlink with a weight equal to the probability of going in that
direction.
Evidently, the sum of the outlink probabilities must equal 1
19 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
For a simple loop, if the loop will be taken a mean of N times, the looping
probability is N/(N + 1) and the probability of not looping is 1/(N + 1).
A link that is not part of a decision node has a probability of 1.
The arithmetic rules are those of ordinary arithmetic.
In this table, in case of a loop, PA is the probability of the link leaving the
loop and PL is the probability of looping.
The rules are those of ordinary probability theory.
If you can do something either from column A with a probability
of PA or from column B with a probability P B, then the probability
that you do either is PA + PB.
For the series case, if you must do both things, and their
probabilities are independent (as assumed), then the probability
that you do both is the product of their probabilities.
For example, a loop node has a looping probability of P L and a probability of
not looping of PA, which is obviously equal to I - PL.
Following the above rule, all we've done is replace the outgoing probability with 1 -
so why the complicated rule? After a few steps in which you've removed nodes,
combined parallel terms, removed loops and the like, you might find something like
this:
20 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
because PL + PA + PB + PC = 1, 1 - PL = PA + PB + PC, and
which is what we've postulated for any decision. In other words, division by
1 - PL renormalizes the outlink probabilities so that their sum equals unity
after the loop is removed.
EXAMPLE:
Let us do this in three parts, starting with case A. Note that the sum of the
probabilities at each decision node is equal to 1. Start by throwing away anything
that isn't on the way to case A, and then apply the reduction procedure. To avoid
clutter, we usually leave out probabilities equal to 1.
CASE A:
21 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
Case B is simpler:
22 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
This checks. It's a good idea when doing this sort of thing to calculate all the
probabilities and to verify that the sum of the routine's exit probabilities does equal
1.
If it doesn't, then you've made calculation error or, more likely, you've left out some
branching probability.
23 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
How about path probabilities? That's easy. Just trace the path of interest and
multiply the probabilities as you go.
Alternatively, write down the path name and do the indicated arithmetic
operation.
Say that a path consisted of links a, b, c, d, e, and the associated probabilities
were .2, .5, 1., .01, and I respectively. Path abcbcbcdeabddea would have a
probability of 5 x 10-10.
Long paths are usually improbable.
1.4.4 MEAN PROCESSING TIME OF A ROUTINE:
Given the execution time of all statements or instructions for every link in a
flowgraph and the probability for each direction for all decisions are to find the
mean processing time for the routine as a whole.
The model has two weights associated with every link: the processing time for
that link, denoted by T, and the probability of that link P.
The arithmetic rules for calculating the mean time:
EXAMPLE:
Start with the original flow graph annotated with probabilities and
processing time.
Combine the parallel links of the outer loop. The result is just the mean of
the processing times for the links because there aren't any other links leaving
the first node. Also combine the pair of links at the beginning of the
flowgraph..
24 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
Use the cross-term step to eliminate a node and to create the inner self -
loop.
Finally, you can get the mean processing time, by using the arithmetic rules
as follows:
25 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
Annotate each link in the graph with the appropriate operator or the null operator 1.
Simplify things to the extent possible, using the fact that a + a = a and 12 = 1.
26 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
You now have a regular expression that denotes all the possible sequences of operators
in that graph. You can now examine that regular expression for the sequences of
interest.
Asanexample,let
A= pp
B= srr
C= rp
T= ss
However,let
A= p + pp + ps
B= psr + ps(r + ps)
C= rp
T= P4
Is it obvious that there is a p4 sequence in ABnC? The theorem states that we have only
to look at
(p + pp + ps)[psr + ps(r + ps)]2rp
Multiplying out the expression and simplifying shows that there is no p4 sequence.
Incidentally, the above observation is an informal proof of the wisdom of looping twice
. Because data-flow anomalies are represented by two-character sequences, it follows
the above theorem that looping twice is what you need to do to find such anomalies.
LIMITATIONS
BTECH_CSE-SEM 41
SVCE
TIRUPATI
anomaly. Such analytical problems go away, of course, if you take the trouble
to design routines for which all paths are achievable.
BTECH_CSE-SEM 41
SVCE
TIRUPATI
Although programmed tools are nice to have, most of the benefits of boolean algebra
can be reaped by wholly manual means if you have the right conceptual tool: the
Karnaugh-Veitch diagram is that conceptual tool.
Figure 1.9 is a limited - entry decision table. It consists of four areas called the condition stub, the
condition entry, the action stub, and the action entry.
Each column of the table is a rule that specifies the conditions under which the actions named in
the action stub will take place.
The condition stub is a list of names of conditions.
29 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
Figure 1.10 : Another Examples of Decision Table.
A rule specifies whether a condition should or should not be met for the rule to be satisfied.
"YES" means that the condition must be met, "NO" means that the condition must not be met, and
"I" means that the condition plays no part in the rule, or it is immaterial to that rule.
The action stub names the actions the routine will take or initiate if the rule is satisfied. If the
action entry is "YES", the action will take place; if "NO", the action will not take place.
The table in Figure 1.9 can be translated as follows:
Action 1 will take place if conditions 1 and 2 are met and if conditions 3 and 4 are not met (rule
1) or if conditions 1, 3, and 4 are met (rule 2).
"Condition" is another word for predicate.
Decision-table uses "condition" and "satisfied" or "met". Let us use "predicate" and TRUE /
FALSE.
Now the above translations become:
1. Action 1 will be taken if predicates 1 and 2 are true and if predicates 3 and 4 are false
(rule 1), or if predicates 1, 3, and 4 are true (rule 2).
2. Action 2 will be taken if the predicates are all false, (rule 3).
3. Action 3 will take place if predicate 1 is false and predicate 4 is true (rule 4).
In addition to the stated rules, we also need a Default Rule that specifies the default action to be
taken when all other rules fail. The default rules for Table in Figure 1.9 is shown in Figure 1.11
o Decision tables can be automatically translated into code and, as such, are a higher-
order language
o If the rule is satisfied, the corresponding action takes place
o Otherwise, rule 2 is tried. This process continues until either a satisfied rule results in
an action or no rule is satisfied and the default action is taken
o Decision tables have become a useful tool in the programmers kit, in business data
processing.
BTECH_CSE-SEM 41
SVCE
TIRUPATI
The specification is given as a decision table or can be easily converted into one.
The order in which the predicates are evaluated does not affect interpretation of the
rules or the resulting action - i.e., an arbitrary permutation of the predicate order will
not, or should not, affect which action takes place.
The order in which the rules are evaluated does not affect the resulting action - i.e., an
arbitrary permutation of rules will not, or should not, affect which action takes place.
Once a rule is satisfied and an action selected, no other rule need be examined.
If several actions can result from satisfying a rule, the order in which the actions are
executed doesn't matter
31 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
CONDITION A YES YES YES NO NO NO
CONDITION B YES NO YES I I I
CONDITION C I I I YES NO NO
CONDITION D YES I NO I YES NO
o Similalrly, If we expand the immaterial cases for the above Table 1.1, it results in
Table 1.2 as below:
o R1 RULE 2 R3 RULE 4 R5 R6
32 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
2. If condition B is met, do process A2 no matter what other actions are taken
or what other conditions are met.
3. If condition C is met, do process A3 no matter what other actions are taken
or what other conditions are met.
4. If none of the conditions is met, then do processes A1, A2, and A3.
5. When more than one process is done, process A1 must be done first, then
A2, and then A3. The only permissible cases are: (A1), (A2), (A3), (A1,A3),
(A2,A3) and (A1,A2,A3).
o Figure 1.13 shows a sample program with a bug.
o The programmer tried to force all three processes to be executed for the cases but
forgot that the B and C predicates would be done again, thereby bypassing processes
A2 and A3.
o Table 1.3 shows the conversion of this flowgraph into a decision table after expansion.
33 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
1.8.1 GENERAL
o Logic-based testing is structural testing when it's applied to structure (e.g., control
flowgraph of an implementation); it's functional testing when it's applied to a
specification.
o In logic-based testing we focus on the truth values of control flow predicates.
o A predicate is implemented as a process whose outcome is a truth-functional value.
o For our purpose, logic-based testing is restricted to binary predicates.
o We start by generating path expressions by path tracing as in Unit V, but this time, our
purpose is to convert the path expressions into boolean algebra, using the predicates'
truth values (e.g., A and ) as weights.
o STEPS:
1. Label each decision with an uppercase letter that represents the truth value
of the predicate. The YES or TRUE branch is labeled with a letter (say A)
and the NO or FALSE branch with the same letter overscored (say ).
2. The truth value of a path is the product of the individual labels.
Concatenation or products mean "AND". For example, the straight-through
path of Figure 6.5, which goes via nodes 3, 6, 7, 8, 10, 11, 12, and 2, has a
truth value of ABC. The path via nodes 3, 6, 7, 9 and 2 has a value of .
3. If two or more paths merge at a node, the fact is expressed by use of a plus
sign (+) which means "OR".
o Using this convention, the truth-functional values for several of the nodes can be
expressed in terms of segments from previous nodes. Use the node name to identify the
point.
34 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
o There are only two numbers in boolean algebra: zero (0) and one (1). One means
"always true" and zero means "always false".
o RULES OF BOOLEAN ALGEBRA:
o In all of the above, a letter can represent a single sentence or an entire boolean algebra
expression.
o Individual letters in a boolean algebra expression are called Literals (e.g. A,B)
o The product of several literals is called a product term (e.g., ABC, DE).
o An arbitrary boolean expression that has been multiplied out so that it consists of the
sum of products (e.g., ABC + DEF + GH) is said to be in sum-of-products form.
35 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
o The result of simplifications (using the rules above) is again in the sum of product form
and each product term in such a simplified version is called a prime implicant. For
example, ABC + AB + DEF reduces by rule 20 to AB + DEF; that is, AB and DEF are
prime implicants.
o The path expressions of Figure 1.14 can now be simplified by applying the rules.
o The following are the laws of boolean algebra:
o Similarly,
o The deviation from the specification is now clear. The functions should have been:
Loops complicate things because we may have to solve a boolean equation to determine what
predicate-value combinations lead to where
36 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
1.9. KV CHARTS
1.9.1 INTRODUCTION
If you had to deal with expressions in four, five, or six variables, you could
get bogged down in the algebra and make as many errors in designing test
cases as there are bugs in the routine you're testing.
Karnaugh-Veitch chart reduces boolean algebraic manipulations to
graphical trivia.
Beyond six variables these diagrams get cumbersome and may not be
effective.
Figure 1.15 shows all the boolean functions of a single variable and their
equivalent representation as a KV chart.
BTECH_CSE-SEM 41
SVCE
TIRUPATI
The charts show all possible truth values that the variable A can
have.
A "1" means the variable’s value is "1" or TRUE. A "0" means that
the variable's value is 0 or FALSE.
The entry in the box (0 or 1) specifies whether the function that the
chart represents is true or false for that value of the variable.
We usually do not explicitly put in 0 entries but specify only the
conditions under which the function is true.
1.9.3 TWO VARIABLES
Figure 6.7 shows eight of the sixteen possible functions of two variables.
38 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
Each box corresponds to the combination of values of the variables
for the row and column of that box.
A pair may be adjacent either horizontally or vertically but not
diagonally.
Any variable that changes in either the horizontal or the vertical
direction does not appear in the expression.
In the fifth chart, the B variable changes from 0 to 1 going down the
column, and because the A variable's value for the column is 1, the
chart is equivalent to a simple A.
Figure 1.17 shows the remaining eight functions of two variables.
39 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
The first chart has two 1's in it, but because they are not adjacent,
each must be taken separately.
They are written using a plus sign.
It is clear now why there are sixteen functions of two variables.
Each box in the KV chart corresponds to a combination of the
variables' values.
That combination might or might not be in the function (i.e., the box
corresponding to that combination might have a 1 or 0 entry).
Since n variables lead to 2n combinations of 0 and 1 for the variables,
and each such combination (box) can be filled or not filled, leading
to 22n ways of doing this.
Consequently for one variable there are 221 = 4 functions, 16
functions of 2 variables, 256 functions of 3 variables, 16,384
functions of 4 variables, and so on.
Given two charts over the same variables, arranged the same way,
their product is the term by term product, their sum is the term by
term sum, and the negation of a chart is gotten by reversing all the 0
and 1 entries in the chart.
OR
40 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
You will notice that there are several ways to circle the boxes into
maximum-sized covering groups.
41 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
The same principles hold for four and more variables that methodology is
embedded can prevent many kinds of bugs
Logic-intensive software designed by the seat of the pants is almost never right. We learned this
lesson decades ago in the simpler hardware logic design arena.
It is in our interest as software engineers to use the simplest possible predicate expressions in our
design.
The objective is not to simplify the code in order to save a few bytes of memory but to reduce the
opportunities for bugs.
Hardware logic designers learned that there were many advantages to designing their logic in a
canonical form—that is, a form that followed certain rules.
The testability considerations of this chapter apply to loop-free software, or to the portion of the
software that is loop-free; for example, a logic-intensive program segment within a loop can be
examined by these means.
Either you can start from specifications or, if you are doing a redesign, from code. I will speak to the
latter case because it is more general.
Think in terms of redesign if you have sensitization difficulties.
Identify your predicates (simple or compound).
If starting from code, get a branch covering set of path predicates.
Interpret the predicates so that they are expressed in terms of the input vector for the
chosen path.
Simplify the path predicate expression for each selected path. If any expression is
logically zero, the path is unachievable. Pick another path or paths to achieve branch
coverage.
If any path predicate expression equals logical I then all other paths must be
unachievable—find and fix the design bug.
The logical sum of the path predicate expressions must equal 1 or else there is an
unsuspected loop, dangling code, or branch coverage is an inadequate test criterion.
The canonical processor has three successive stages:
Predicate calculator.
Logic analyzer.
Domain processor.
The predicate calculator transforms (e.g., processes) the input vector to get the values of the variables
that are actually used in the predicates. Every predicate is evaluated exactly once, so that it’s truth
value is known.
The logic analyzer forms the predicate expression appropriate to the case and directs the control flow
to the appropriate
Domain processor. Because each predicate defines a domain boundary and each predicate expression
defines a domain, there is a one-to-one correspondence between the various outcomes of the logic
analyzer and the domains.
The domain processor does the processing appropriate to each domain, for example, with a separate
hunk of code for each domain. Only one control-flow statement (a case statement) is needed—one
42 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
case, one predicate expression, one domain. The canonical form, if it is achieved, has the following
obvious advantages:
Branch coverage and all-paths coverage are identical.
All paths are achievable and easy to sensitize.
Separation simplifies maintenance.
The above canonical form is an ideal that you cannot expect to achieve. Achieving it could mean
redundant software, excessive nesting depth (if you encapsulate the redundancies in subroutines), or
slow execution on some paths; conversely, however, the canonical form can be faster and tighter.
You may be able to achieve it locally or globally but not both; but you do not know unless you try.
And why try? Because it works. The proof comes from hardware design, where we learned, three
decades ago, that seat-of-the-pants logic was buggy, slow, dangerous, and hard to build, test, and
maintain
9. Practice Quiz
1. aa* =
a) a*a
b) a+
c) a*
d) Both a and b
2. Two successive path segments is expressed by concatenation is known as
a) Path product
b) Path sum
c) Path
d) Path Expression
3. The first steps in node reduction is
A )Combine all parallel links
b) Combine all Serial links
c) Remove self loops
d) Remove the node
4. The weight expression of series path of A and B in lower path count arithmetic is
a) WA + WB
b) WA
c) Max(WA , WB )
d) Min(WA , WB )
5. If the probability of looping node is PL , the probability of non looping node is
a) 1- PL
b) 1+ PL
c) PL
d) PL *
6. Which among the following is not a complementary operation
a) PUSH/POP
b) START/STOP
c) OPEN/CLOSE
d) None
7. The main goal of reduction process is
43 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
a) To reduce nodes
b) To retain only entry and exit nodes
c) Remain with single node
d) Remove loops
8. The main step in achieving the node reduction is
a) parallel term
b) Serial term
c) Loop term
d) Cross Term
9. To remove elements from stack, the operation used is
a) POP
b) Remove
c) Delete
d) None
10. If G is get operation then G+G would be
a) 2G
b) G
c) G2
d) 0
11. The decision table has a disadvantage of
a) Insufficient program logic
b) No clarity
c) Implicit relation to specification
d) Low level maintainability
12. If there are k predicates then the maximum number of predicate cases possible are
A) 2k
b) 2k
c) 2k-1
d) 2k-1
13. The proportional calculus in which there are more than two truth values in known as
a) Multiway Predicate
b) Multivalued logic
c) Multiway truth
d) None
14. ABC+BCD+CDE+EFG is in the form of
a) Sum of products
b) Product of additions
c) Reduction of sums
d) Product of sums
15. ABCD+BCD+CD+AB can be reduced to
a) CD+AB
b)1
c) CD
d) AB
16. The first step in reducing Boolean expression is
a) Replace identical terms
44 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
b) Remove parenthesis
c) The term containing a variable and its compliment is removed
d) None
17. The order of grouping in KV charts should be
a) Octets, islands, pairs, quads
b) Octets, quads, pairs, islands
c) quads, pairs, islands, Octets
d) islands, pairs, quads, Octets
18. For n predicates, the no of interchanges for each combination of predicate truth values would be
a) n(n-1)/2
b)2n
c) n2
d) n(n-1)
19. The list of names of conditions is known as
a) Condition Stub
b) Condition Entry
c) Action Entry
d) Action stub
20. The rules that are used when all the rules failed to meet the conditions are
a) Contional rules
b) Action rules
c) Action entries
d) Default rules
21. If there are 2 immaterial cases in a table then the expansion would result in _______columns or cases
a) 4
b) 8
c)16
d) 2
22. Which among the following is true for predicate values
a) They are not restricted to binary truth values
b) They are restricted to binary truth values in logic based testing
c) Both a and b
d) None
10.Assignments
S.No Question BL CO
1 Define Path Expression, Path product, Path sum and . 2 1
2 Explain Node Reduction algorithm 2 1
3 Describe various applications in Path 2 1
4 Define Regular Expression and Data flow anomaly detection 2 1
5 Discuss about Decision table 3 1
45 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
S.No Question & Answers BL CO
1 Define PATH PRODUCTS?
1 1
Ans. path name is also called a path product.
2 Define PATH EXPRESSION?
1 1
Ans. Decision, Biosis, Mitosis, Junction, Absorption, Conjugation
3 Define CROSS-TERM STEP?
1 1
Ans. It removes a node, thereby reducing the number of nodes by one
4 Define Decision table?
Ans. The functional requirements of many programs can be specified by decision 1 1
tables, which provide a useful basis for program and test design.
5 List various components in Decision table?
Ans. 1. Condition stub 2. Condition entry 3. Action Stub 4. Action 1 1
entry
6 Explain knowledge-based system?
Ans. The knowledge-based system (also expert system, or "artificial intelligence"
1 1
system) has become the programming construct of choice for many
applications that were once considered very difficult.
7 Define Predicate?
Ans. A predicate is implemented as a process whose outcome is a truth- 2 1
functional value.
8 Explain about KV charts?
Ans. Karnaugh-Veitch chart reduces boolean algebraic manipulations to 2 1
graphical trivia.
S.No Question BL CO
1 Describe Node Reduction algorithm 1 1
2 Explain Maximum and minimum path count 2 1
3 Explain Probability path count and Mean time path count 2 1
4 Discuss about Regular Expression and Data flow anomaly detection? 3 1
Explain Haung’s Theorem?
5 Discuss about Decision tables and its elements 3 1
6 Explain KV chart or Reduce the following functions using K-Maps F(A,B,C,D) =
P(4,5,6,7,8,12,13)+d(1,15)
7 Demonstrate by means of truth tables the validity of the following theorems of
Boolean algebra: i. Associative Laws ii. Demorgan's theorems for three variables
iii. Distributive Law iv. Absorption Rule
8 Explain about the ambiguities and contradictions in specifications?
BTECH_CSE-SEM 41
SVCE
TIRUPATI
and Smoke Testing Multilanguage support and compatibility Testing
2 Mobile Application Testing 1
UI Testing, Rule based Testing, Regression Testing, Functional Testing, Security
Testing
K-Map is used for minimization or simplification of a Boolean expression. 2-4 variable K-maps are easy
to handle. However, the real challenge is 5 and 6 variable K-maps. Visualization of 5 & 6 variable K-map is
a bit difficult. When the number of variables increases, the number of the square (cells) increases. And
drawing the K-map becomes a bit complicated because of drawing the adjacent cells.
5 Variables K-Map
5 variables have 32 min terms,which mean 5 variable karnaugh map has 32 squares (cells).
A 5-variable K-map is made using two 4-variable K-maps. Consider 5 variables A,B,C,D,E.
their 5 variable K-map is given below.
Example
of 5 Variables K-Map
47 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
F (A,B,C,D,E) = ∑ ( m0, m2, m5, m7, m8, m10, m16, m21, m23, m24, m27, m31 )
This is the 5-variable k-map for the function given above. There are four groups made in this K-map. Each
group has a different color to differentiate between them.
The red color group is a group of 4 min terms made between both 4-variable k-maps because they are
adjacent cells and it overlaps the green group.
The yellow group is also a group of 4 min terms made between adjacent cells of the 4-variable k-maps.
The green group is a group of 4 min terms made in the left 4-variable k-map. The blue group is of 2 min-
terms made in the right 4-variable k-map because there are no common adjacent cells in the other k-map.
Green color group of 4 min term will produce the term A̅C̅E̅. The individual 4-variable K-map will produce
C̅E̅ as they are not changing in the group but variable A should also be taken into account because this
individual 4-variable k-map is being represented by A̅.
The red color group will produce C̅D̅E̅. This group is made between both K-maps which means variable A
changes and in individual K-map, B changes so these both variables will be eliminated from the term. Only
C̅D̅E̅ remains unchanged in this group.
The yellow group will produce B̅CE because these literals are not changing in this group.
Blue group of 2 min terms will produce the term ABDE as they remain unchanged in this group.
The simplified expression will be the sum of these 4 terms, which is given below:
F = A̅C̅E̅ + C̅D̅E̅ + B̅CE + ABDE
4 Effective methods of Software Testing, Perry, John Wiley, 2nd Edition, 1999.
17. Mini Project Suggestion
48 | S T - U N I T - I V
BTECH_CSE-SEM 41
SVCE
TIRUPATI
1. Android Task Monitoring
This project is exclusively designed to simplify the tracking and monitoring of day-to-day activities of the
busy modern life. We are so busy in our daily lives right now that it becomes impossible to keep track of our
daily events, meetings, and appointments. To address this issue, this project focuses on developing a Weekly
Task Alerting System for Android devices that can alert users of the tasks/appointments that are scheduled
for each day in a week.
The project is primarily a reminder app powered by an AI chatbot that reminds users of all the tasks that are
due daily. Users can use this application to set goals and achieve them, thereby increasing productivity and
simplifying their lives.
49 | S T - U N I T - I V
BTECH_CSE-SEM 41