STM Question Bank Solutions-2023-24
STM Question Bank Solutions-2023-24
STM Question Bank Solutions-2023-24
1. Define testing.
Testing: Testing is the process of verifying whether application works as per the requirements or not.
The quality and productivity of a software is measured by testing. Testing starts with known
conditions, uses predefined procedures and has predictable outcomes. Testing proves a
programmer's failure.
a) Bug prevention
Bug prevention: Bug Prevention is considered as testing’s first goal. If a bug is present in the software
it is needed to be detected and corrected. If such a bug is prevented there is no need to correct it or
detect it and the cost of testing will be decreased. Hence, we say bug prevention is better than bug
detection and bug correction.
Bug Detection/ Bug discovery: How much ever we try the first goal can not be achieved ideally
because “to err is human”. If we fail to achieve the first goal second is bug discovery.
In functional testing, the program or system is treated as a blackbox. It is subjected to inputs, and its
outputs are verified for conformance to specified behavior. Functional testing takes the user point of
view- bother about functionality and features and not the program's implementation.
Structural testing does look at the implementation details. Things such as programming style, control
method, source language, database design, and coding details dominate structural testing.
Both Structural and functional tests are useful, both have limitations, and both target different kinds
of bugs. Structural tests are inherently finite but cannot detect all errors even if completely executed.
A module can be defined as a distinct, small component that has a well-defined purpose while
constructing the system , it could be easy to understand if each component used in the system is
small.
As it is known that each component interact with the other component by means of interface. If the
system is made up of many smaller components, it could be affected with interface bugs. Then its
efficiency could fall down. These bugs in the system can be reduced by considering larger
components but large components have internal logic which is difficult to understand.
A unit is usually the work of one programmer and consists of several hundred or fewer lines of code.
Unit Testing is the testing we do to show that the unit does not satisfy its functional specification or
that its implementation structure does not match the intended design structure.
Integration Testing: Integration is the process by which components are aggregated to create larger
components. Integration Testing is testing done to show that even though the componenets were
individually satisfactory (after passing component testing), checks the combination of components
are incorrect or inconsistent.
Typical initialization bugs include: Forgetting to initialize the variables before first use, assuming that
they are initialized elsewhere, initializing to the wrong format, representation or type etc.
A data flow anomaly occurs where there is a path along which we expect to do something
unreasonable with data, such as using an uninitialized variable, attempting to use a variable before it
exists, modifying and then not storing or using the result, or initializing twice without an
intermediate use.
PREDICATE: The logical function evaluated at a decision is called Predicate. The direction taken at a
decision depends on the value of decision variable. Some examples are: A>0, x+y>=90.......
PATH PREDICATE: A predicate associated with a path is called a Path Predicate. For example, "x is
greater than zero", "x+y>=90", "w is either negative or equal to 10 is true" is a sequence of
predicates whose truth values will cause the routine to take a specific path.
SHORT ANSWERS
UNIT-2
1. What is transaction?
A transaction is a unit of work seen from a system user's point of view. A transaction consists of a
sequence of operations, some of which are performed by a system, persons or devices that are
outside of the system. Transaction begin with Birth-that is they are created as a result of some
external act. At the conclusion of the transaction's processing, the transaction is no longer in the
system.
Births: There are three different possible interpretations of the decision symbol, or nodes with two
or more out links. It can be a Decision, Biosis or a Mitosis.
Decision: Here the transaction will take one alternative or the other alternative but not both.
Biosis: Here the incoming transaction gives birth to a new transaction, and both transaction continue
on their separate paths, and the parent retains its identity.
Mitosis: Here the parent transaction is destroyed and two new transactions are created
• Ordinary Junction: An ordinary junction which is similar to the junction in a control flow
graph. A transaction can arrive either on one link or the other.
• Absorption: In absorption case, the predator transaction absorbs prey transaction. The prey
gone but the predator retains its identity.
• Conjugation: In conjugation case, the two parent transactions merge to form a new
daughter. In keeping with the biological flavor this case is called as conjugation.
4. What is van Neumann machine architecture?
The Von Neumann machine Architecture executes one instruction at a time in the following, micro
instruction sequence:
• Interpret instruction
• Fetch operands
• Process or Execute
• Store result
• GOTO 1
DATA FLOW TESTING: Data flow testing is the name given to a family of test strategies based on
selecting paths through the program's control flow in order to explore sequences of events related to
the status of data objects.
For example, pick enough paths to assure that every data object has been initialized prior to use or
that all defined objects have been used for something.
Domain Testing is a software testing technique in which selecting a small number of test cases from
a nearly infinite group of test cases.
For testing few applications, domain specific knowledge plays a very crucial rule.
Domain testing is type of functional testing and tests the application by feeding interesting inputs
and evaluating its outputs.
Complete Boundaries are the one which does not have any gaps between them. Nice domain
boundaries have complete boundaries because they cover from plus infinity to minus infinity.
Incomplete boundaries, shows that the Boundaries C and E have gaps. Such boundaries can come
about because the path that hypothetically corresponds to them is unachievable, because inputs are
constrained in such a way that such values cannot exist or because redundant predicates convert
such boundary values into a null set.
9. What is convex?
A geometric figure (in any number of dimensions) is convex if you can take two arbitrary points on
any two different boundaries, join them by a line and all points on that line lie within the figure.
The above figure explains the convex property. In convex, 𝑃𝑄 lies inside the graph and in next case
𝑃𝑄 is outside the geometric figure.
10. What is interior point and boundary point?
An interior point is a point in the domain such that all points within an arbitrarily small distance
(called an epsilon neighborhood) are also in the domain.
A boundary point is one such that within an epsilon neighborhood there are points both in the
domain and not in the domain.
LONG ANSWERS
UNIT-1
Phases in a tester's mental life can be categorized into the following 5 phases:
1. Phase 0: (Until 1956: Debugging Oriented) There is no difference between testing and debugging.
Phase 0 thinking was the norm in early days of software development till testing emerged as a
discipline.
2. Phase 1: (1957-1978: Demonstration Oriented) the purpose of testing here is to show that
software works. Highlighted during the late 1970s. This failed because the probability of showing
that software works 'decreases' as testing increases. I.e. the more you test, the more likely you will
find a bug.
3. Phase 2: (1979-1982: Destruction Oriented) the purpose of testing is to show that software
doesn’t work. This also failed because the software will never get released as you will find one bug or
the other. Also, a bug corrected may also lead to another bug.
4. Phase 3: (1983-1987: Evaluation Oriented) the purpose of testing is not to prove anything but to
reduce the perceived risk of not working to an acceptable value (Statistical Quality Control). Notion is
that testing does improve the product to the extent that testing catches bugs and to the extent that
those bugs are fixed. The product is released when the confidence on that product is high enough.
(Note: This is applied to large software products with millions of code and years of use.)
5. Phase 4: (1988-2000: Prevention Oriented) Testability is the factor considered here. One reason is
to reduce the labor of testing. Other reason is to check the testable and non-testable code. Testable
code has fewer bugs than the code that's hard to test. Identifying the testing techniques to test the
code is the main key here.
2. Discuss pesticide paradox and complexity barrier method.
3. Compare a) Testing Vs Debugging b) Designer Vs Tester.
A) Testing Vs Debugging
Testing Debugging
Testing can and should be planned, designed and Procedure and duration of debugging cannot be so
scheduled. constrained.
Testing, as executes, should strive to be predictable, Debugging demands intuitive leaps, experimentation
dull, constrained, rigid and inhuman. and freedom.
Much of test execution and design can be automated. Automated debugging is still a dream.
4. Explain A Model for Testing with neat diagram.
The process of testing can be done on anything from subroutines to systems which consists of
millions of statements. For any system or product to be produced a perfect planning and
implementation is necessary.
ENVIRONMENT:
o A Program's environment is the hardware and software required to make it run. For
online systems, the environment may include communication lines, other systems,
terminals and operators.
o The environment also includes all programs that interact with and are used to create
the program under test - such as OS, linkage editor, loader, compiler, utility routines.
o Programmers behave in such a way that they should not blame the environment that
may be software or hardware for the occurrence of the bugs. As the hardware and
software are stable ,there is no need to considering the complexity of the
environment.
o Some times unexpected results occur because of testing, the environment could also
be wrong. The bug could be in the hardware or firmware.
PROGRAM:
• If simple model of the program does not explain the unexpected behavior, we may have to
modify that model to include more facts and details. And if that fails, we may have to modify
the program
BUGS:
Bugs are more insidious (deceiving but harmful) than ever we expect them to be. It cant be predicted
when will be the bug occur. The behavior of the bug will be as such. But bugs can be categorized into
Initialization bugs
Call sequence bugs
Wrong variable bugs
And so on…
An Unexpected result some times will change the model of the bugs.
A)
• Requirements and specifications developed from them can be incomplete ambiguous, or self-
contradictory. They can be misunderstood or impossible to understand.
• The specifications that don't have flaws in them may change while the design is in progress.
The features are added, modified and deleted.
• Requirements, especially, as expressed in specifications are a major source of expensive bugs.
• The range is from a few percentage to more than 50%, depending on the application and
environment.
• What hurts most about the bugs is that they are the earliest to invade the system and the last
to leave.
Feature Bugs:
• Providing correct, clear, implementable and testable feature specifications is not enough.
• Features usually come in groups or related features. The features of each group and the
interaction of features with in the group are usually well tested.
• The problem is unpredictable interactions between feature groups or even between individual
features. For example, your telephone is provided with call holding and call forwarding. The
interactions between these two features may have bugs.
• Every application has its peculiar set of features and a much bigger set of unspecified feature
interaction potentials and therefore result in feature interaction bugs.
b) Logic bugs
• Bugs in logic, especially those related to misundertanding how case statements and logic
operators behave singly and combinations
• Also includes evaluation of boolean expressions in deeply nested IF-THEN-ELSE constructs.
• If the bugs are parts of logical (i.e. boolean) processing not related to control flow, they are
characterized as processing bugs.
• If the bugs are parts of a logical expression (i.e control-flow statement) which is used to direct
the control flow, then they are categorized as control-flow bugs.
CONTROL FLOW GRAPHS:The control flow graph is a graphical representation of a program's control
structure. It uses the elements named process blocks, decisions, and junctions.
The flow graph is similar to the earlier flowchart, with which it is not to be confused.
Flow Graph Elements:A flow graph contains four different types of elements. (1) Process Block (2)
Decisions (3) Junctions (4) Case Statements
Process Block:
Decisions:
Junctions:
• A junction is a point in the program where the control flow can merge.
• Examples of junctions are: the target of a jump or skip instruction in ALP, a label that is a target
of GOTO.
PATH TESTING CRITERIA:Any testing strategy based on paths must at least both exercise every
instruction and take branches in all directions.A set of tests that does this is not complete in an
absolute sense, but it is complete in the sense that anything less must leave something untested.So
we have explored three different testing criteria or strategies out of a potentially infinite family of
strategies
Path Testing (Pinf):
• Execute all possible control flow paths through the program: typically, this is restricted to all
possible entry/exit paths through the program.
• If we achieve this prescription, we are said to have achieved 100% path coverage. This is the
strongest criterion in the path testing strategy family: it is generally impossible to achieve.
• Execute all statements in the program at least once under some test. If we do enough tests
to achieve this, we are said to have achieved 100% statement coverage.
• An alternate equivalent characterization is to say that we have achieved 100% node
coverage. We denote this by C1.
• This is the weakest criterion in the family: testing less than this for new software is
unconscionable (unprincipled or can not be accepted) and should be criminalized.
• Execute enough tests to assure that every branch alternative has been exercised at least
once under some test.
• If we do enough tests to achieve this prescription, then we have achieved 100% branch
coverage.
• An alternative characterization is to say that we have achieved 100% link coverage.
• For structured software, branch testing and therefore branch coverage strictly includes
statement coverage.
• We denote branch coverage by C2.
Which paths to be tested? You must pick enough paths to achieve C1+C2. The question of what is
the fewest number of such paths is interesting to the designer of test tools that help automate the
path testing, but it is not crucial to the pragmatic (practical) design of tests. It is better to make many
simple paths than a few complicated paths.
Practical Suggestions in Path Testing:Draw the control flow graph on a single sheet of paper.
• Make several copies - as many as you will need for coverage (C1+C2) and several more.
• Use a yellow highlighting marker to trace paths. Copy the paths onto a master sheets.
• Continue tracing paths until all lines on the master sheet are covered, indicating that you
appear to have achieved C1+C2.
• As you trace the paths, create a table that shows the paths, the coverage status of each
process, and each decision.
• Link Marker:A simple and effective form of instrumentation is called a traversal marker or
link marker.
• Instrument the links so that the link's name is recorded when the link is executed.
Why Single Link Markers aren't enough: Unfortunately, a single link marker may not do the trick
because links can be chewed by open bugs.
We intended to traverse the ikm path, but because of a rampaging GOTO in the middle of the m link,
we go to process B. If coincidental correctness is against us, the outcomes will be the same and we
won't know about the bug.
The solution to the problem of single link marker method is to implement two markers per link: one
at the beginning of each link and on at the end.
The two link markers now specify the path name and confirm both the beginning and end of the link
UNIT-2
LONG ANSWERS
A transaction is a unit of work seen from a system user's point of view.A transaction consists of a
sequence of operations, some of which are performed by a system, persons or devices that are
outside of the system.Transaction begin with Birth-that is they are created as a result of some
external act.At the conclusion of the transaction's processing, the transaction is no longer in the
system.
Example of a transaction: A transaction for an online information retrieval system might consist of
the following steps or tasks:
• Do input processing
• Search file
• Accept input
• Validate input
• Process request
• Update file
• Transmit output
– A :- anomalous
• These capital letters (K,D,U,A) denote the state of the variable and should not be confused
with the program action, denoted by lower case letters.
• Unforgiving Data - Flow Anomaly Flow Graph:Unforgiving model, in which once a variable
becomes anomalous it can never return to a state of grace.
Assume that the variable starts in the K state - that is, it has not been defined or does not exist. If an
attempt is made to use it or to kill it (e.g., say that we're talking about opening, closing, and using
files and that 'killing' means closing), the object's state becomes anomalous (state A) and, once it is
anomalous, no action can return the variable to a working state. If it is defined (d), it goes into the D,
or defined but not yet used, state. If it has been defined (D) and redefined (d) or killed without use
(k), it becomes anomalous, while usage (u) brings it to the U state. If in U, redefinition (d) brings it to
D, u keeps it in U, and k kills it.
Forgiving Data - Flow Anomaly Flow Graph:Forgiving model is an alternate model where redemption
(recover) from the anomalous state is possible.
This graph has three normal and three anomalous states and he considers the kk sequence not to
be anomalous. The difference between this state graph and Figure is that redemption is possible. A
proper action from any of the three anomalous states returns the variable to a useful working
state.
4. Describe strategies of dataflow testing.
STRATEGIES OF DATA FLOW TESTING:
• INTRODUCTION:Data Flow Testing Strategies are structural strategies.
• In contrast to the path-testing strategies, data-flow strategies take into account what
happens to data objects on the links in addition to the raw connectivity of the graph.
• In other words, data flow strategies require data-flow link weights (d,k,u,c,p).
• Data Flow Testing Strategies are based on selecting test path segments (also called sub
paths) that satisfy some characteristic of data flows for all data objects.
• For example, all subpaths that contain a d (or u, k, du, dk).
Terminology
Definition Clear Path Segment:
• Clear Path Segment with respect to variable X, is a connected sequence of links such that X is
(possibly defined on the first link and not redefined or killed on any subsequent link of that
path segment
• All paths in image (a) are definition clear because variables X and Y are defined only on the
first link (1, 3) and not thereafter
Image (b)shows more complicated situation. The following path segments are definition-clear:
(1, 3, 4), (1, 3, 5), (5, 6, 7, 4), (7, 8, 9, 6, 7), (7, 8, 9, 10),(7, 8,10) (7, 8, 10, 11)
Sub graph (1, 3, 4, 5) is not definition-clear because the variable is defined on (1, 3) and again on (4,
5)
For practice, try finding all the definition-clear subparts for this routine (i.e. for all variables)
In figure, incomplete boundaries, shows that the Boundaries C and E have gaps. Such boundaries can
come about because the path that hypothetically corresponds to them is unachievable, because
inputs are constrained in such a way that such values cannot exist or because redundant predicates
convert such boundary values into a null set.
c) Systematic Boundaries :
• Systematic boundary means that boundary inequalities related by a simple function
such as a constant.
• In figure below, for example, the domain boundaries for u and v differ only by a
constant.
• Two boundary sets U and V (See below figure(a)) are said to be orthogonal, if every
inequality in V is perpendicular to every inequality in U.
• If two boundary sets are orthogonal, then they can be tested independently.
• In figure (a), we have six boundaries in U and four in V.
• We can confirm the boundary properties in a number of tests proportional to 6 + 4 = 10 (or
O(n)).
e) Closure Consistency :
• Consistent closure means that there is a simple pattern to the closures – for example, using
the same relational operator for all boundaries of a set of parallel boundaries.
f) Convex :
• A geometric figure (in any number of dimensions) is convex if you can take two arbitrary
points on any two different boundaries, join them by a line and all points on that line lie
within the figure.
• Nice domains are convex; dirty domains aren’t.
• The above figure explains the convex property. In convex, 𝑃𝑄 lies inside the graph and in
next case 𝑃𝑄 is outside the geometric figure.
g) Simply Connected :
• Nice domains are simply connected; that is, they are in one piece rather than pieces all over
the place interspersed with other domains. It means that all the domains are considered as a
single piece.
• Simple connectivity is a weaker requirement than convexity; if a domain is convex it is simply
connected, but not vice versa.
7. Discuss about ugly domains.
• Some domains are born ugly and some are uglified by bad specifications.
• Every simplification of ugly domains by programmers can be either good or bad.
• Programmers in search of nice solutions will "simplify" essential complexity out of existence.
Testers in search of brilliant insights will be blind to essential complexity and therefore miss
important cases.
• The ugly domains are simplified to get nice solutions. The simplifications made by the
programmers and testers may be either good or bad.
• AMBIGUITIES AND CONTRADICTIONS:
• Domain ambiguities are holes in the input space.
• The holes may lie within the domains or in cracks between domains.
• Two kinds of contradictions are possible: overlapped domain specifications and
overlapped closure specifications
• Figure shows overlapped domains shows dual closure assignment
Figure shows the twelve different ways the caller and the called can disagree about closure. Not all of
them are necessarily bugs. The four cases in which a caller boundary is open and the called is closed
(marked with a "?") are probably not buggy. It means that the caller will not supply such values but
the called can accept them.
SPAN COMPATIBILITY:
Figure shows three possibly harmless span incompatibilities.
• In all cases, the caller's range is a subset of the called's domain. That's not
necessarily a bug.
In Figure b the ranges and domains don't line up; hence good values are rejected, bad values are
accepted, and if the called routine isn't robust enough, we have crashes.
Figure c combines these notions to show various ways we can have holes in the domain: these are all
probably buggy.
Shifted Boundary: In Figure 4.15b the bug is a shift up, which converts part of domain B
into A processing, denoted by A'. This result is caused by an incorrect constant in a
predicate, such as x + y >= 17 when x + y >= 7 was intended. The off point (closed off
outside) catches this bug. Figure 4.15c shows a shift down that is caught by the two on
points.
Tilted Boundary: A tilted boundary occurs when coefficients in the boundary inequality
are wrong. For example, 3x + 7y > 17 when 7x + 3y >17 was intended. Figure 4.15d has a
tilted boundary, which creates erroneous domain segments A' and B'. In this example the bug
is caught by the left on point.
Extra Boundary: An extra boundary is created by an extra predicate. An extra boundary
will slice through many different domains and will therefore cause many test failures for
the same bug. The extra boundary in Figure 4.15e is caught by two on points, and
depending on which way the extra boundary goes, possibly by the off point also.
Missing Boundary: A missing boundary is created by leaving a boundarypredicate out.
A missing boundary will merge different domains and will cause many test failures
although there is only one bug. A missing boundary, shown in Figure 4.15f, is caught by
the two on points because the processing for A and B is the same - either A or B
processing.
SHORT ANSWERS
UNIT-3
Every link of a graph can be given a name.The link name will be denoted by lower case italic letters.In
tracing a path or path segment through a flow graph, you traverse a succession of link names.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.
Consider a pair of nodes in a graph and the set of paths between those node.
ac+abc+abbc+abbbc+abbbbc+...........
The + sign is understood to mean "or" between the two nodes of interest, paths ac, or abc, or abbc,
and so on can be taken.
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.".
If X and Y denote the same set of paths, then the union of these sets is unchanged; consequently,
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
It follows that any arbitrary sum of identical path expressions reduces to the same path expression.
• Structured code can be defined in several different ways that do not involve ad-hoc rules
such as not using GOTOs.
• A structured flowgraph is one that can be reduced to a single link by successive application of
the transformations of Figure
5. What are the three arithmetic cases of counting maximum number of path?
There are three cases of interest: parallel links, serial links, and loops.
The knowledge-based system (also expert system, or "artificial intelligence" system) has become the
programming construct of choice for many applications that were once considered very difficult.
Knowledge-based systems incorporate knowledge from a knowledge domain such as medicine, law,
or civil engineering into a database. The data can then be queried and interacted with to provide
solutions to problems in that domain.
• 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.
8. Write a short note on single variable KV Charts.
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.
AB
A+B
A (NOTB)
10.What is default action?
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
SHORT ANSWERS
UNIT-4
1. Define State.
A state is defined as: “A combination of circumstances or attributes belonging for the time being to a
person or thing.”
A state in a state graph is the node which represents the characteristics and behavior of the system.
State graph has set of states and they are identified by characters or numbers.
For example, a moving automobile whose engine is running can have the following states with
respect to its transmission.
▪ Reverse gear
▪ Neutral gear
▪ First gear
▪ Second gear
▪ Third gear
• Fourth gear
The behaviour of the system is represented in graphical form which is known as state graph. The
state graph is used for functional testing of the system to identify different bugs.
• States
• Inputs
• Transitions
• Outputs
A dead state is a state that once entered cannot be left. This is not necessarily a bug but it is
suspicious. If the software was designed to be the fuse for a bomb, we would expect at least one
such state.
Good state graph: A state graph is said to be good, when every state, input, transition and output is
specified clearly and understandable.
Bad state graph: A state graph is said to be good, when every state, input, transition and output is
not specified clearly and difficult to understand.
5. What is Encoding Bugs?
The process of converting or coding the inputs, transitions and outputs of the states in order to
obtain the secure process of the finite sate machine is known as encoding. Encoding is done both in
explicit and implicit way. The probability of bugs is more in explicit finite state machine
implementation. Bugs can even occur in implicit finite state machine.
The states, the transitions, and the inputs could be correct, there could be no dead or unreachable
states, but the output for the transition could be incorrect. Output actions must be verified
independently of states and transitions. The tester has to needs to distinguish the state graph that is
correct and whose output is incorrect.
State table:
Time Sequence
The rows corresponding to the two states are identical with respect to input/output/next state but
the name of the next state could differ. The two states are differentiated only by the input that
distinguishes between them.
There are two sets of rows which, except for the state names, have identical state graphs with
respect to transitions and outputs. The two sets can be merged.
SHORT ANSWERS
UNIT-5
A graph matrix is a square array with one row and one column for every node in the graph.
Each row-column combination corresponds to a relation between the node corresponding to the row
and the node corresponding to the column.
The relation for example, could be as simple as the link name, if there is a link between the nodes.
The cyclomatic complexity obtained by subtracting 1 from the total number of entries in each row
and ignoring rows with no entries, we obtain the equivalent number of decisions for each row.
Adding these values and then adding 1 to the sum yields the graph’s cyclomatic complexity.
The connection matrix is obtained by replacing each entry with 1 if there is a link and 0 ifthere
isn’t. As usual we don’t write down 0 entries to reduce the clutter.
A partial ordering relation satisfies the reflexive, transitive, and antisymmetric properties.
Partial ordered graphs have several important properties: they are loop free, there is at
least onemaximum element, and there is at least one minimum element.
5. Give any few advantages of a graph matrix representation?
Whenever a graph is used as a model, sooner or later we trace paths through it to find a set of
covering paths, a set of values that will sensitize paths, the logic function that controls the flow, the
processing time of the routine, the equations that define the domain, or whether a state is reachable or
not.
Path is not easy, and it’s subject to error. You can miss a link here and there or cover some links
twice.
One solution to this problem is to represent the graph as a matrix and to use matrix operations
equivalent to path tracing. These methods are more methodical and mechanical and don’t depend on
your ability to see a path they are more reliable.
• Each entry in the graph’s matrix expresses a relation between the pair of nodes
that corresponds to that entry.
• Squaring the matrix yields a new matrix that expresses the relation between
each pair of nodes via one intermediate node under the assumption that the
relation is transitive.
• The square of the matrix represents all path segments two links long.
• The third power represents all path segments three links long.
Given a matrix whose entries are aij, the square of that matrix is obtained by replacing every
entry with
n
o aij=Σ aikakj
k=1
UNIT-3
PATH PRODUCTS:
• Normally flow graphs used to denote only control flow connectivity.
• The simplest weight we can give to a link is a name.
• Using link names as weights, we then convert the graphical flow graph into an equivalent
algebraic like expressions which denotes the set of all possible paths from entry to exit for
the flow graph.
• Every link of a graph can be given a name.
• The link name will be denoted by lower case italic letters.
• In tracing a path or path segment through a flow graph, you traverse a succession of link
names.
• 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.
• 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.
• PATH SUMS:The "+" sign was used to denote the fact that path names were part of the same
set of paths.
• Links a and b in Figure (a) 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.
• 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.
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
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
REDUCTION PROCEDURE ALGORITHM: 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.
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.
Let us see by applying this algorithm to the following graph where we remove several nodes
in order; that is
Label each link with a link weight that corresponds to the number of paths that link
represents.
Also mark each loop with the maximum number of times that loop can be taken. If the
answer is infinite, you might as well stop the analysis because it is clear that the
maximum number of paths will be infinite.
There are three cases of interest: parallel links, serial links, and loops.
Each link represents a single link and consequently is given a weight of"1" to start. Let’s say
the outer loop will be taken exactly four times andinner Loop Can be taken zero or three times
Its path expression, with a little work, is:
1. For the Inner Loop:
D:Calculate the total weight of inner loop, which can execute a min. of 0times and max. of 3
times. So, it inner loop can be evaluated as follows:
13 = 10 + 11 + 12 + 13 = 1 + 1 + 1 + 1 = 4
E: Multiply the link weights inside the loop: 1 X 4 = 4
F: Evaluate the loop by multiplying the link wieghts: 2 X 4 = 8.
G: Simpifying the loop further results in the total maximum number ofpaths in the
flowgraph: 2 X 84 X 2 = 32,768.
4. Derive lower path count arithmetic for below flow graph.
A lower bound on the number of paths in a routine can be approximated for structured flow
graphs.
The arithmetic is as follows:
If you observe the original graph, it takes at least two paths to cover andthat it can
be done in two paths.
PUSH / POP:
Here is the Push/Pop Arithmetic:
▪ G(G + R)G(GR)*GGR*R
= G(G + R)G3R*R
= (G + R)G3R*
= (G4 + G2)R*
▪ This expression specifies the conditions under which the
resources will be balanced on leaving the routine.
6. Construct below program structure into decision table.
• DECISION TABLE:
• DECISION TABLE:
KV CHARTS:
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.
• THREE VARIABLES:
o KV charts for three variables are shown below.
o As before, each box represents an elementary term of three
variables with a bar appearing or not appearing according to
whether the row-column heading for thatbox is 0 or 1.
o A three-variable chart can have groupings of 1, 2, 4, and 8 boxes.
o A few examples will illustrate the principles:
A four variable KV Chart and other possible adjacencies is shown in the below figure
9. Discuss troublesome program with example.
10. Derive mean processing time routine for below flow graph.
Given the execution time of all statements or instructions for every link in a flowgraph and
theprobability 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,
denotedby T, and the probability of that link P.
The arithmetic rules for calculating the mean time:
EXAMPLE:
1. Start with the original flow graph annotated with probabilities and processing
time.
2. 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
flow graph.
3. Combine as many serial links as you can.
4. Use the cross-term step to eliminate a node and to create the inner self -
loop. 5.Finally, you can get the mean processing time, by using the
arithmetic rules as follows:
LONG ANSWERS
UNIT-4
1. Discuss about
a) State
b) State Graph
c)State table
A state is defined as: “A combination of circumstances or attributes belonging for the time being to a
person or thing.”
A state in a state graph is the node which represents the characteristics and behavior of the system.
State graph has set of states and they are identified by characters or numbers.
For example, a moving automobile whose engine is running can have the following states with
respect to its transmission.
▪ Reverse gear
▪ Neutral gear
▪ First gear
▪ Second gear
▪ Third gear
• Fourth gear
State graph.
The behaviour of the system is represented in graphical form which is known as state graph. The
state graph is used for functional testing of the system to identify different bugs.
• States
• Inputs
• Transitions
• Outputs
State graph -
Example
• For example, a program that detects the character sequence “ZCZC” can be
in thefollowing states.
• Neither ZCZC nor any part of it has been detected.
▪ Z has been detected.
▪ ZC has been detected.
▪ ZCZ has been detected.
▪ ZCZC has been detected.
States are represented by Nodes. State are numbered or may identified by wordsor whatever
else is convenient.
State Tables
• It’s more convenient to represent the state graph as a table (the state table or state
transition table) that specifies the states, the inputs, the transitions and the
outputs.
• The following conventions are used:
• Each row of the table corresponds to a state.
• Each column corresponds to an input condition.
• The box at the intersection of a row and a column specifies the next state (the
transition) and the output, if any.
1. Number of States:
A State graph consists of the number of states. It represents behaviour of the system.
In practice the state is directly or indirectly recorded.
State table is used to record the number of states of the state graph.
To find the missing states, first find the number of states
The number of states is founded by as follows.
1. Identify all the component factors of the state.
2. Identify all the allowable values for each factor.
3. Now the number of states is the product of the factors and allowable values.
2. Impossible States:
A state that is not possible is called impossible states.
For example a broken engine cannot run, so running a broken engine state is impossible state.
There are some combination of factors that are impossible, they are
GEAR: R, N, 1, 2, 3, 4 = 6 factors
DIRECTION: forward, reverse, stopped = 3 factors
ENGINE: running, stopped = 2 factors
TRANMISSION: ok, broken = 2 factors
ENGINE: ok, broken = 2 factors
TOTAL = 6 x 3 x 2 x 2 x2 =144 states.
A broken engine cannot run so the combination of engine is 3 states. Therefore, the total number of
states is 108. A car with a broken transmission does not move for long, there by further decreasing
the number of states.
3. Equivalent States
• Two states are Equivalent if every sequence of inputs starting from one state
produces exactly the same sequence of outputs when started from the other
state. This notion can also be extended to set of states.
Equivalent States
• Two states are Equivalent if every sequence of inputs starting from one state
produces exactly the same sequence of outputs when started from the other
state. This notion can also be extended to set of states.
e/y
A C
a
e/y
1
e/x
b
e/x
B C
d/y
Here except a, b inputs, the system behavior in two states A, B are identical for every
input sequence.
STATE OK ERROR
1 A1/u B1/u
A1 A1/y A2/x
B1 B1/y B2/x
A2 B2/w A3/u
B2 A2/w B3/u
A3 A3/u B2/y
B3 B3/u A2/y
The merged equivalent states are represented by as follows
5. Discuss about Transition Bugs.
Rule 1:
❖ The program will maintain an error counter which will be incremented
whenever there is an error. Here there are only two input values OK, ERROR.
❖ These values make it easier to detect ambiguities and contradictions in a state
table.
INPUT
STATE OK ERROR
0 0/NONE 1/
1 2/
2 3/
3 4/
4 5/
5 6/
6 7/
7 8/
Rule 2:If there is an error rewrite the block.
INPUT
STATE OK ERROR
0 0/NONE 1/REWRITE
1 2/REWRITE
2 3/REWRITE
3 4/REWRITE
4 5/REWRITE
5 6/REWRITE
6 7/REWRITE
7 8/REWRITE
Rule 3: If there are three errors, erase 10 centimeters of tape and rewrite the block.
INPUT
STATE OK ERROR
0 0/NONE 1/REWRITE
1 2/REWRITE
2 3/REWRITE,ERASE,REWRITE
3 4/REWRITE,ERASE,REWRITE
4 5/REWRITE,ERASE,REWRITE
5 6/REWRITE,ERASE,REWRITE
6 7/REWRITE,ERASE,REWRITE
7 8/REWRITE,ERASE,REWRITE
Rule 4: If there are three erasures and another error occur, then put out of service
INPUT
STATE OK ERROR
0 0/NONE 1/REWRITE
1 2/REWRITE
2 3/ERASE,REWRITE
3 4/ERASE,REWRITE
4 5/ERASE,REWRITE
5 6/OUT
6
7
Rule 5:
❖ If the erasure was successful return to the normal state and clear the error
counter.
INPUT
STATE OK ERROR
0 0/NONE 1/REWRITE
1 2/REWRITE
2 3/ERASE,REWRITE
3 0/NONE 4/ERASE,REWRITE
4 0/NONE 5/ERASE,REWRITE
5 0/NONE 6/OUT
6
Rule 6:
❖ If the rewrite was unsuccessful increment the error counter, and try another
rewrite.
Rule 7:
❖ If the rewrite was successful decrement the error counter and return to the
previous state.
INPUT
STATE OK ERROR
0 0/NONE 1/REWRITE
1 0/NONE 2/REWRITE
2 1/NONE 3/ERASE,REWRITE
3 0/NONE 4/ERASE,REWRITE
2/NONE
4 0/NONE 5/ERASE,REWRITE
3/NONE
5 0/NONE 6/OUT
4/NONE
6
State testing:
• State testing is defined as a functional testing technique to test the functional bugs in
the entire system.
• The principles for state testing are very similar to the principles of path testing.
Principles:
• State testing is defined as a functional testing technique to test the functional bugs in
the entire system.
• The principles for state testing are very similar to the principles of path testing.
• For path testing it is not possible to test every possible path in a flowgraph.
• Similarly for state testing it is not possible to test every possible path in a state graph.
• Simply identifying the factors that contribute to the state, calculating the total number of
states, and comparing this number to the designer’s notion catches some bugs.
• Insisting on a justification for all supposedly dead, unreachable, and impossible states and
transitions catches a few more bugs.
• Insisting on an explicit specification of the transition and output for every combination of
input and state catches many more bugs.
• A set of input sequences that provide coverage of all nodes and links is a mandatory
minimum requirement.
• In executing state tests, it is essential that means be provided (e.g., instrumentation
software) to record the sequence of states (e.g., transitions) resulting from the input
sequence and not just the outputs that result from the input sequence.
7. Explain advantages and disadvantages of state testing and limitations & extensions of state
testing.
State testing:
State testing is defined as a functional testing technique to test the functional bugs in the
entire system.
The principles for state testing are very similar to the principles of path testing
Advantages:
Disadvantages:
• State testing does not provide thorough testing because when a test is completed, there
might be some bugs remained in the system.
• Testers require large number of input sequence s to catch transition errors, missing states,
extra states and the link.
• Simply identifying the factors that contribute to the state, calculating the total number of
states, and comparing this number to the designer’s notion catches some bugs.
• Insisting on a justification for all supposedly dead, unreachable, and impossible states and
transitions catches a few more bugs.
• Insisting on an explicit specification of the transition and output for every combination of
input and state catches many more bugs.
• A set of input sequences that provide coverage of all nodes and links is a mandatory
minimum requirement.
• In executing state tests, it is essential that means be provided (e.g., instrumentation
software) to record the sequence of states (e.g., transitions) resulting from the input
sequence and not just the outputs that result from the input sequence.
➢ In figure a flag is set to p in the program. This p variable is assigned to some value
which can be evaluated.
➢ Depending on its value a path is separated into branches in order to proceed
testing in either way that is u or x
➢ This also can be done by removing a flag and separating v path into two different
paths w,y as shown in the above figure.
➢ Unachievable paths those paths which don’t interact with each other.
➢ Here there are four paths u,w,x,y in that two are not achievable and two are
achievable.
➢ That is u is not achievable to path y and path x is not achievable to path w & u is
achievable to path w and path x is achievable to path y.
➢ Finally both the paths uw and xy are needed to cover the branches.
➢ In the above figure there are three flag variables p,q,r in the program.
➢ These variables are assigned some values that can be evaluated and based on
which the paths are separated into branches.
The main benefit of using this implementation is to remove the unnecessary combination
from the decision tree as shown.
10. Discuss essential and Inessential finite state behaviour.
• A graph matrix is a square array with one row and one column for every node in the graph.
• Each row-column combination corresponds to a relation between the node corresponding to
the row and the node corresponding to the column.
• The relation for example, could be as simple as the link name, if there is a link between the
nodes.
➢ Similarly
(A+I)n = I+A1+A2+A3+…An
➢ Now the original expression becomes
∞
∑ Ai = A(I+A1+A2+A3+…+A∞) = A(A+I)∞
i=1
➢ If the paths of length n-1, where n is the number of nodes, the set of all such paths
is
n-1
∑ Ai = A(A+I)n-2
i=1
15
∑ Ai = A(A+I)8(A+I)4(A+I)2
i=1
A matrix for which A2=A is said to be idempotent matrix. A matrix whose successive power
gives an idempotent matrix is called idempotent generator. The nth power of a matrix A + I
over a transitive relation is called the transitive closure of the matrix.
3. Explain connection matrix with an example.
Connection matrix
• The connection matrix is obtained by replacing each entry with 1 if there is a link
and 0 if thereisn’t.
• As usual we don’t write down 0 entries to reduce the clutter.
• Each row of a matrix denotes the out links of the node corresponding to that row.
• Each column denotes the in links corresponding to that node.
• A branch is a node with more than one nonzero entry in its row.
• A junction is node with more than one nonzero entry in its column.
• A self loop is an entry along the diagonal.
Converting to connection matrix:
1 1
1 1
1 1 1
A graph matrix is a square array with one row and one column for every node in the graph.
Each row-column combination corresponds to a relation between the node corresponding to the row
and the node corresponding to the column.
The relation for example, could be as simple as the link name, if there is a link between the nodes.
There is a place to put every possible direct connection or link between any and any other node.
The entry at a row and column intersection is the link weight of the link that connects the two nodes
in that direction.
Connection matrix
• The connection matrix is obtained by replacing each entry with 1 if there is a link
and 0 if thereisn’t.
• As usual we don’t write down 0 entries to reduce the clutter.
Cyclomatic Complexity
The cyclomatic complexity obtained by subtracting 1 from the total number of entries in each
row and ignoring rows with no entries, we obtain the equivalent number of decisions for
each row. Adding these values and then adding 1 to the sum yields the graph’s cyclomatic
complexity.
Relation
Reflexive Relations:
❖ A relation R is reflexive if for every a, aRa. This relation represents a self-
loop at every node.
❖ Examples of reflexive relations are: equals, is a relative of, etc.
❖ Examples of irreflexive relations include: not equals, is a friend of, etc.
Symmetric Relations:
❖ A relation R is symmetric if aRb then bRa. This relation represents if a link from
a to b then there is also a link from b to a.
❖ A graph whose relations are symmetric is called an undirected graph and a
graph whose relations are not symmetric is called a directed graph
❖ Examples of symmetric relations are: a relative of, is brother of, etc.
❖ Examples of asymmetric relations are: is the boss of, is greater than, etc.
Antisymmetric Relations:
❖ A relation R is antisymmetric, if aRb and bRa, then a = b.
❖ Examples of antisymmetric relations are: is greater than or equal to, is a subset of,
etc.
Examples of nonantisymmetric relations are: is connected to, is a relative of, etc.
Equivalence Relations
• An equivalence relation is a relation that satisfies the reflexive, transitive,
and symmetricproperties.
• Equality is the most familiar example of an equivalence relation.
• If a set of objects satisfy an equivalence relation, we say that they form an
equivalence class overthat relation.
• The importance of equivalence classes and relations is that any member of the
equivalence classis, with respect to the relation, equivalent to any other member
of that class.
• The idea behind partition testing strategies such as domain testing and path
testing, is that we canpartition the input space into equivalence classes.
• Testing any member of the equivalence class is as effective as testing the mall.
• more generally, given two matrices A and B with entries aik and bkj, respectively, their
product is a new matrix C, whoseentries are cij,where:
n
• Cij=Σ aikbkj
k=1
8. Describe partitioning algorithm.
Partitioning Algorithm:
It is an algorithm which is used to transform the graphs with loops into loop free graphs.
There are certain points to remember here. They are
1. A graph is loop free at the top level.
2. Many graphs with loops are easy to analyze, if you know where to break the
loops.
3. This algorithm is used to develop a tool which can identify the loops.
The partition algorithm represents. (A+I)n # (A+I)nT
Example:
➢ Consider the following flowgraph and its graph matrix (A + I).
The transitive closure matrix (A+I)n can be obtained by using the following
steps. Step:1: Mark all diagonal entries by 1
Step:2: The flow from node 1 to node 6 is 1-2-7-2-3-4-5-3-4-6
So mark nodes 1,2,3,4,5,6,7 by 1 in the first row
Step:3: The flow from node 2 to node 6 is 2-7-2-3-4-5-3-4-6
So mark nodes 2,3,4,5,6 by 1 in the second row.
Step:4: The flow from node 3 to node 6 is 3-4-5-3-4-6.
So mark nodes 3,4,5,6 by 1 in the third row
So on…
(A+I)n =
➢ The intersection of transitive closure matrix (A+I)n and transpose matrix (A+I)nT
is given by, identifying similar rows and column entries from (A+I)n and (A+I)nT
9. Explain node reduction algorithm.
The advantage of matrix reduction method is that it is more methodical than the graphical
methodcalled as node by node removal algorithm.
1. Select a node for removal; replace the node by equivalent links that bypass
that node and addthose links to the links they parallel.
2. Combine the parallel terms and simplify as you can.
3. Observe loop terms and adjust the out links of every node that had a self loop to
account for theeffect of the loop.
4. The result is a matrix whose size has been reduced by 1. Continue until only
the two nodes of interest exist.
Removing the loop term yields (bfh*e)
x
(bfh*e)* (d+bc+bfh*g)