STM Question Bank Solutions-2023-24

Download as pdf or txt
Download as pdf or txt
You are on page 1of 84

SOFTWARE TESTING METHODOLOGIES

QUESTION BANK SOLUTIONS


SHORT ANSWERS
UNIT-1

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.

2. What are goals of testing?


The two main goals of testing are

a) Bug prevention

b) Bug detection/ Bug discovery

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.

3. Define functional testing.

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.

4. Define structural testing.

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.

5. Compare modularity vs efficiency

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.

6. What is unit testing and integration testing?

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.

7. What are feature bugs?

• Specification problems usually create corresponding feature problems.


• A feature can be wrong, missing, or superfluous (serving no useful purpose). A missing
feature or case is easier to detect and correct. A wrong feature could have deep design
implications.
• Removing the features might complicate the software, consume more resources, and foster
more bugs.

8. Define initialization and data flow bugs.


Initialization bugs are common. Initialization bugs can be improper and superfluous.

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.

Data-Flow Bugs and Anomalies:

Most initialization bugs are special case of data flow anomalies.

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.

9. Compare control flow graph vs flow chart.

• A program's flow chart resembles a control flow graph.


• In flow graphs, we don't show the details of what is in a process block.
• In flow charts every part of the process block is drawn.
• The flowchart focuses on process steps, where as the flow graph focuses on control flow of
the program.
• The act of drawing a control flow graph is a useful tool that can help us clarify the control
flow and data flow issues.
10. Define predicate and path predicate.

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.

2. List types of births with diagrams.

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

3. List types of mergers with diagrams.


• Mergers:Transaction flow junction points are potentially as troublesome as transaction flow
splits. There are three types of junctions: (1) Ordinary Junction (2) Absorption (3)
Conjugation

• 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?

Most computers today are von-Neumann machines.

The Von Neumann machine Architecture executes one instruction at a time in the following, micro
instruction sequence:

• Fetch instruction from memory

• Interpret instruction

• Fetch operands

• Process or Execute

• Store result

• Increment program counter

• GOTO 1

5.What is dataflow testing?

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.

6. Define domain testing.

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.

7. Compare specified and implemented domains.

• Specified Domains : Specified domains can be incomplete and/or inconsistent. Incomplete in


this context means that there are input vectors for which no path is specified, and
inconsistent means that there are at least two contradictory specifications over the same
segment of the input space.

• Implemented Domains : Implemented domains can't be incomplete or inconsistent. Every


input will be processed (rejection is a process), possibly forever. Inconsistent domains will be
made consistent.
8. Define complete and incomplete boundaries.

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.

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.
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

1.Explain about phases in tester’s mental life.

Phases in a tester's mental life:

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

Debugging starts from possibly unknown intial


Testing starts with known conditions, uses predefined
conditions and the end can not be predicted except
procedures and has predictable outcomes.
statistically.

Testing can and should be planned, designed and Procedure and duration of debugging cannot be so
scheduled. constrained.

Testing is a demonstration of error or apparent


Debugging is a deductive process.
correctness.

Debugging is the programmer's vindication


Testing proves a programmer's failure.
(Justification).

Testing, as executes, should strive to be predictable, Debugging demands intuitive leaps, experimentation
dull, constrained, rigid and inhuman. and freedom.

Debugging is impossible without detailed design


Much testing can be done without design knowledge.
knowledge.

Testing can often be done by an outsider. Debugging must be done by an insider.

Much of test execution and design can be automated. Automated debugging is still a dream.
4. Explain A Model for Testing with neat diagram.

A MODEL FOR TESTING:

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.

Above figure is a model of testing process. It includes three models:

A model of the environment,

A model of the program,

A model of the expected bugs.


From these models we create a set of test which are then executed. The result of each test is either
expected or unexpected. If unexpected it may lead to revise the test, our model or concept how the
program behaves , our concept of what bugs are possible ,or the program itself. Only rarely would we
attempt to modify the environment.

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:

• Most programs are too complicated to understand in detail.

• The concept of the program is to be simplified in order to test it.

• 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.

5. Discuss about Consequences of bugs.


• IMPORTANCE OF BUGS: The importance of bugs depends on frequency, correction cost,
installation cost, and consequences.
1. Frequency: How often does that kind of bug occur? Pay more attention to the more
frequent bug types.
2. Correction Cost: What does it cost to correct the bug after it is found? The cost is the
sum of 2 factors: (1) the cost of discovery (2) the cost of correction. These costs go
up dramatically later in the development cycle when the bug is discovered.
Correction cost also depends on system size.
3. Installation Cost: Installation cost depends on the number of installations: small for a
single user program but more for distributed systems. Fixing one bug and
distributing the fix could exceed the entire system's development cost.
4. Consequences: What are the consequences of the bug? Bug consequences can
range from mild to catastrophic.

A reasonable metric for bug importance is
• Importance= ($) = Frequency * (Correction cost + Installation cost + Consequential cost)
• CONSEQUENCES OF BUGS: The consequences of a bug can be measure in terms of human
rather than machine. Some consequences of a bug on a scale of one to ten are:
1. Mild: The symptoms of the bug offend us aesthetically (gently); a misspelled output or a
misaligned printout.
2. Moderate: Outputs are misleading or redundant. The bug impacts the system's performance.
3. Annoying: The system's behaviour because of the bug is dehumanizing. E.g1. Names are shortend
or changed. Eg2:Bills for even null amount are sent.
4. Disturbing: It refuses to handle legitimate (authorized / legal) transactions. Eg:The ATM wont give
you money. Eg: My credit card is declared invalid.
5. Serious: It loses track of its transactions. Not just the transaction itself but the fact that the
transaction occurred. Accountability is lost.
6. Very Serious: The bug causes the system to do the wrong transactions. Instead of losing your
paycheck, the system credits it to another account or converts deposits to withdrawals.
7. Extreme: The problems aren't limited to a few users or to few transaction types. They are frequent
and arbitrary instead of sporadic (infrequent) or for unusual cases.
8. Intolerable: Long term unrecoverable corruption of the database occurs and the corruption is not
easily discovered. Serious consideration is given to shutting the system down.
9. Catastrophic: The decision to shut down is taken out of our hands because the system fails.
10.Infectious: What can be worse than a failed system? One that corrupt other systems even though
it does not fall in itself ; that erodes the social physical environment; that melts nuclear reactors ,kills
the system.

6. Explain a) Requirements, features and functionality bugs.


b) Logic bugs

A)

REQUIREMENTS, FEATURES AND FUNCTIONALITY BUGS: Various categories in Requirements,


Features and Functionlity bugs include:

Requirements and Specifications Bugs:

• 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:

• Specification problems usually create corresponding feature problems.


• A feature can be wrong, missing, or superfluous (serving no useful purpose). A missing feature
or case is easier to detect and correct. A wrong feature could have deep design implications.
• Removing the features might complicate the software, consume more resources, and foster
more bugs.

Feature Interaction 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.

7. What is control flow graph? Explain flow graph elements.

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:

• A process block is a sequence of program statements uninterrupted by either decisions or


junctions.
• It is a sequence of statements such that if any one of statement of the block is executed, then
all statement thereof are executed.
• Formally, a process block is a piece of straight line code of one statement or hundreds of
statements.
• A process has one entry and one exit. It can consists of a single statement of instruction, a
sequence of statements or instructions, a single entry/exit subroutine, a macro or function call,
or a sequence of these.

Decisions:

• A decision is a program point at which the control flow can diverge.


• Machine language conditional branch and conditional skip instructions are examples of
decisions.
• Most of the decisions are two-way but some are three way branches in control flow.
Case Statements:

• A case statement is a multi-way branch or decisions.


• Examples of case statement are a jump table in assembly language, and the PASCAL case
statement.
• From the point of view of test design, there are no differences between Decisions and Case
Statements

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.

8. Explain Path testing, statement testing, branch testing.

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.

Statement Testing (P1):

• 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.

Branch Testing (P2):

• 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.

9. Explain which paths to be selected for below flow graph.


And draw one table for paths, decisions and process links.

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.

• The above paths lead to the following table considering

10. Explain Single and Two link markers with diagram.

• Link Marker:A simple and effective form of instrumentation is called a traversal marker or
link marker.

• Name every link by a lower case letter.

• 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.

Two Link Marker Method:

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

1. Explain transaction with example.

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:

• Accept input (tentative birth)

• Validate input (birth)

• Transmit acknowledgement to requester

• Do input processing

• Search file

• Request directions from user

• Accept input

• Validate input

• Process request

• Update file

• Transmit output

• Record transaction in log and clean up (death)

2. Discuss transaction flow testing techniques.

TRANSACTION FLOW TESTING TECHNIQUES:


GET THE TRANSACTIONS FLOWS:
– Complicated systems that process a lot of different, complicated transactions should
have explicit representations of the transactions flows, or the equivalent.
INSPECTIONS, REVIEWS AND WALKTHROUGHS:
Transaction flows are natural agenda for system reviews or inspections.
In conducting the walkthroughs, you should:
• Discuss enough transaction types to account for 98%-99% of the transaction the system is
expected to process.
• Discuss paths through flows in functional rather than technical terms.
• Ask the designers to relate every flow to the specification and to show how that transaction,
directly or indirectly, follows from the requirements.
Design more test cases to validate all births and deaths.
• PATH SELECTION:
– Select a set of covering paths (c1+c2) using the analogous criteria you used for
structural path testing.
– Select a covering set of paths based on functionally sensible transactions as you
would for control flow graphs.
– Try to find the most tortuous, longest, strangest path from the entry to the exit of
the transaction flow.
• PATH SENSITIZATION:
– Most of the normal paths are very easy to sensitize-80% - 95% transaction flow
coverage (c1+c2) is usually easy to achieve.
– The remaining small percentage is often very difficult.
– Sensitization is the act of defining the transaction. If there are sensitization problems
on the easy paths, then bet on either a bug in transaction flows or a design bug.
• PATH INSTRUMENTATION:
– Instrumentation plays a bigger role in transaction flow testing than in unit path
testing.
– The information of the path taken for a given transaction must be kept with that
transaction and can be recorded by a central transaction dispatcher or by the
individual processing modules.
– In some systems, such traces are provided by the operating systems or a running log.

3. Explain dataflow anomaly state graph.


• DATA FLOW ANOMALY STATE GRAPH:Data flow anomaly model prescribes that an object can
be in one of four distinct states:

– K :- undefined, previously killed, doesnot exist

– D :- defined but not yet used for anything

– U :- has been used for computation or in predicate

– 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)

Loop-Free Path Segment:


It is a path segment for which every node in it is visited at most once
Example: Path (4,5,6,7,8, 10) in image (b) is loop free, but path (10, 11, 4, 5, 6, 7, 8, 10, 11, and 12) is
not because nodes 10 and 11 are each visited twice

Simple Path Segment:


It is a path segment in which at most one node is visited twice
Example: In image (b), (7, 4, 5, 6 and 7) is a simple path segment. a simple path segment is either
loop-free or if there is a loop, only one node is involved
5. Explain all du paths, APU+C and ACU+P strategies forbelow diagram.

• Strategies in Data Flow Testing are:

All-du Paths (ADUP)


The all-du-paths strategy is the strongest data flow testing strategy
It requires that every du path form every definition of every variable to every use of that definition
be exercise under some test
For variable X
In image, because variable X are used only on link (1, 3) any test that starts at the entry satisfies this
criterion (for variable X, but not for all variables as required by the strategy)
All p-uses/some c-uses strategy (APU + C)
• For every variable and every definition of that variable, include at least one definition free
path from the definition to every predicate use
• If there are definitions of the variables that are not covered by the above prescription, and
then add computational use test cases as required to cover every definition
• For variable Z
In image for APU + C we can select paths that all take the upper link (12, 13) and therefore we do not
cover the c-use of Z but that's okay according to the strategy's definition because every definition is
covered Links (1,3), (4,5), (5,6) and (7,8) must be included because they contain definitions for
variable z Links (3,4), (3,5), (8,9) (8,10), (9,6) and (9,10) must be included because they contain
predicate uses of Z Find a covering set of test cases under APU + C for all variables in this example - it
only takes two test

All c-uses/some p-uses strategy (ACU + P)


The all c-uses/some p-uses strategy (ACU+P) is to first ensure coverage by computational use cases
• If any definition is not covered by the previously selected paths, add such predicate use cases
as are needed to assure that every definition is included in some test

6. Discuss about nice domains.


There are some properties that should be satisfied by the domain boundaries so that they can be
called as Nice Domains.
• To the extent that domains have these properties, domain testing is easy as testing gets.
• The frequency of bugs is also less in nice domain.
• The following are the important properties of Nice domains:
a) Linear and Non-Linear Boundaries
b) Complete Boundaries
c) Systematic Boundaries
d) Orthogonal Boundaries
e) Closure Consistency
f) Convex
g) Simply Connected
a) Linear and Non-Linear Boundaries :
• Nice domain boundaries are defined by linear inequalities or equations (– after
interpretation in terms of input variables).
• Linear boundaries are more frequently used than the non-linear boundaries.
• We can linearize these non-linear boundaries by using simple transformations.
b) Complete Boundaries :
• 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.
• One of the main advantages of a complete boundary is that it requires only one set of tests
to verify the boundary irrespective of the number of surrounding domains.

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.

where fi is an arbitrary linear function,


X is the input vector,
ki and c are constants, and
g(i,c) is a decent function over i and c that yields a constant, such as k + ic.
• The first example is a set of parallel lines, and the second example is a set of
systematically (e.g., equally) spaced parallel lines (such as the spokes of a wheel, if
equally spaced in angles, systematic).
d) Orthogonal Boundaries :

• 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

• SIMPLIFYING THE TOPOLOGY:


• The programmer's and tester's reaction to complex domains is the same - simplify
• There are three generic cases: concavities, holes and disconnected pieces.
• Programmers introduce bugs and testers misdesign test cases by: smoothing out
concavities ,filling in holes , and joining disconnected pieces .
• RECTIFYING BOUNDARY CLOSURES:
If domain boundaries are parallel but have closures that go every which way (left, right, left . . .) the
natural reaction is to make closures go the same way

8. Explain closure compatibility and span compatibility with diagrams.


CLOSURE COMPATIBILITY:
• Assume that the caller's range and the called domain spans the same numbers - for
example, 0 to 17.
• Figure shows the four ways in which the caller's range closure and the called's
domain closure can agree.
• The thick line means closed and the thin line means open. Figure shows the four
cases consisting of domains that are closed both on top (17) and bottom (0), open
top and closed bottom, closed top and open bottom, and open top and bottom.

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.

9. Explain about testing one dimensional domain.

TESTING ONE DIMENSIONAL DOMAIN:


The closure can be wrong (i.e., assigned to the wrong domain) or the boundary (a point
in this case) can be shifted one way or the other, we can be missing a boundary, or we
can have an extraboundary.
• Figure 4.13 shows possible domain bugs for a one-dimensional open domain
boundary.
• In Figure 4.13a we assumed that the boundary was to be open for A. The bug
we're looking for is a closure error, which converts > to >= or < to <= (Figure
4.13b). One test (marked x) on the boundary point detects this bug because
processing for that point will go to domain A rather than B.
• In Figure 4.13c we've suffered a boundary shift to the left. The test point we used
for closure detects this bug because the bug forces the point from the B domain,
where it should be, to A processing. Note that we can't distinguish between a
shiftand a closure error, but we do know that we have a bug.

Figure 4.13: One Dimensional Domain Bugs, Open Boundaries.


• Figure 4.13d shows a shift the other way. The on point doesn't tell us anything
because the boundary shift doesn't change the fact that the test point will be
processed in B. To detect this shift we need a point close to the boundary but
within A. The boundary is open, therefore by definition, the off point is in A
(Open Off Inside).
• The same open off point also suffices to detect a missing boundary because what
should have been processed in A is now processed in B.
• To detect an extra boundary we have to look at two domain boundaries. In this
context an extra boundary means that A has been split in two. The two off points
that we selected before (one for each boundary) does the job. If point C had
beena closed boundary, the on test point at C would do it.
• For closed domains look at Figure 4.14. As for the open boundary, a test point
on the boundary detects the closure bug. The rest of the cases are similar to the
open boundary, except now the strategy requires off points just outside the
domain.

10. Describe testing two dimensional domains.

• TESTING TWO DIMENSIONAL DOMAINS:

1. Figure 4.15 shows possible domain boundary bugs for a two-dimensional


domain.
2. A and B are adjacent domains and the boundary is closed with
respect to A, which means that it is open with respect to B.
Figure 4.15: Two Dimensional Domain Bugs.
For Closed Boundaries:
Closure Bug: Figure 4.15a shows a faulty closure, such as might be caused byusing
a wrong operator (for example, x >= k when x > k was intended, or vice versa). The
two on points detect this bug because those values will get B ratherthan A processing.

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

1. Define path product.

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.

2. What are path expressions?

Consider a pair of nodes in a graph and the set of paths between those node.

Alternatively, the same set of paths can be denoted by :

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.".

3. What is absorption Rule?

If X and Y denote the same set of paths, then the union of these sets is unchanged; consequently,

RULE :X+X=X (Absorption Rule)

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.

4.What is Structured flowgraph?

• 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.

6. What is knowledge-based system?

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.

7. What is 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.
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.

9.Convert AB, A+B, A(NOT B) expressions into Two variable KV Chart.

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

2. Define 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.

State graph include many elements such as

• States
• Inputs
• Transitions
• Outputs

3. What is dead State?

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.

4. Compare good state graph and bad state graph.

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.

6.What are output errors?

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.

7. Define FSM and State tables.

The finite-state machine is as fundamental to software engineering as Boolean algebra. A finite-state


machine is an abstract device that can be represented by a state graph having a finite number of states
and a finite number of transitions between states.

State table:

• 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 column specifies the next state (the transition) and
the output, if any

8. What is impact of bugs in state testing?

• Wrong number of states.


• Wrong transition for a given state-input combination.
• Wrong output for a given transition.
• Pairs of states or sets of states that are inadvertently made equivalent (factor lost).
• States or sets of states that are split to create inequivalent duplicates.
• States or sets of states that have become dead.
• States or sets of states that have become unreachable.
9. Compare time and sequence.

Time Sequence

1. State graphs don’t represent time 1.State graphs represent sequence.

A transition might take The state graph would be the same


microseconds or centuries; a system because it has no notion of time
could be in one state for
milliseconds and another for eons,
or the other way around;

10. What is equivalent states?

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

1.Define Graph Matrix.

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.

2.What is 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.

3. What is connection matrix?

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.

4. Mention some characteristics of partial ordered graphs?

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.

6. What is a relation? And transitive relation?


A relation is a property that exists between two objects of interest.
• For example,
• “Node a is connected to node b” or aRb where “R” means “is connected to”.
• “a>=b” or aRb where “R” means greater than or equal”.
A relation is transitive if aRb and bRc implies aRc.
Most relations used in testing are transitive.
Examples of transitive relations include: is connected to, is greater than or equal to, is less than or
equal to, is a relative of, is faster than, is slower than, takes more time than, is a subset of, includes,
shadows, is the boss of

7. Write about power of matrix?

• 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

8. Write a short note on product of matrices?


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
9. What is in-degree and out-degree?

In-degree: The in-degree of a node is the number of in links it has.

out-degree: The out-degree of a node is the number of out links it has.

10. What is degree and average degree?

Degree: The degree of a node is the sum of in-degree and out-degree

Average degree: Average degree(mean) of a node is between 3 and 4.


LONG ANSWERS

UNIT-3

1. Explain path product and path sums.

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.

• The "PATH SUM" denotes paths in parallel between nodes.

• 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

2. Apply reduction procedure for below flow graph.

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.

• 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.
Let us see by applying this algorithm to the following graph where we remove several nodes
in order; that is

o Remove node 10 by applying step 4 and combine by step 5 to yield

o Remove node 9 by applying step4 and 5 to yield

o Remove node 7 by steps 4 and 5, as follows:

o Remove node 8 by steps 4 and 5, to obtain:


o PARALLEL TERM (STEP 6):
Removal of node 8 above led to a pair of parallel links between nodes 4 and 5.
combine them to create a path expression for an equivalent link whose path
expression is c+gkh;that is

o LOOP TERM (STEP 7):


Removing node 4 leads to a loop term. The graph has now been replaced with the
following equivalent simpler graph:

o Continue the process by applying the loop-removal step as follows:

o Removing node 5 produces:

o Remove the loop at node 6 to yield:

o Remove node 3 to yield

o 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
3. Derive maximum path count arithmetic for below flow graph.

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.

5. Discuss push/pop and get/return methods.

PUSH / POP:
Here is the Push/Pop Arithmetic:

▪ The numeral 1 is used to indicate that nothing of interest


(neither PUSHnor POP) occurs on a given link.
▪ "H" denotes PUSH and "P" denotes POP. The
operations arecommutative, associative, and
distributive.
▪ Consider the following flow graph:

P(P + 1)1{P(HH)n1HP1(P + H)1}n2P(HH)n1HPH


▪ Simplifying by using the arithmetic tables,
= (P2 + P){P(HH)n1(P + H)}n1(HH)n1
= (P2 + P){H2n1(P2 + 1)}n2H2n1
GET / RETURN:
Exactly the same arithmetic tables used for previous example are used forGET /
RETURN a buffer block or resource, or, in fact, for any pair of complementary
operations in which the total number of operations in either direction is cumulative.
▪ The arithmetic tables for GET/RETURN are:

"G" denotes GET and "R" denotes RETURN.


▪ Consider the following flowgraph:

▪ 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:

• Below Figure is a limited - entry decision table. It consists of four areas


called the conditionstub, 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 actionsnamed in the action stub will take place.
• The condition stub is a list of names of conditions.

• Decision tables can also be used to examine a program's structure.

• Figure shows a program segment that consists of a decision tree.

• These decisions, in various combinations, can lead to actions 1, 2, or 3.


If the decision appears on a path, put in a YES or NO as appropriate. If the decision does not appear
on the path, put in an I, Rule 1 does not contain decision C, therefore its entries are: YES, YES, I, YES.

The corresponding decision table is

Similalrly, If we expand the immaterial cases for the above Table

7. Explain decision table with example.

• DECISION TABLE:

• Below Figure is a limited - entry decision table. It consists of four areas


called the conditionstub, 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 actionsnamed in the action stub will take place.
• The condition stub is a list of names of conditions.

• A more general decision table can be as below:


• 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.

8. Explain Three variable and Four variable KV Charts with examples.

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.

• If condition A is met, do process A1 no matter what other actions are


taken or what other conditions are met.
• If condition B is met, do process A2 no matter what other actions are
taken or what other conditions are met.
• If condition C is met, do process A3 no matter what other actions are
taken or what other conditions are met.
• If none of the conditions is met, then do processes A1, A2, and A3.
• 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).
Figure 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.
Table shows the conversion of this flow graph into a decision table after expansion.

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.

State graph include many elements such as

• 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.

2. Explain about good and bad state graphs.

Good State Graphs and Bad State Graphs


• What constitutes a good or a bad state graph is to some extent biased by
the kinds of stategraphs that are likely to be used in a software test design
context.
• Here are some principles for judging.
o The total number of states is equal to the product of the possibilities
of factors thatmake up the state.
o For every state and input there is exactly one transition specified to
exactly one,possibly the same, state.
o For every transition there is one output action specified. The
output could betrivial, but at least one output does something
sensible.
o For every state there is a sequence of inputs that will drive the
system back to thesame state.

Examples of Bad state graphs

3. Discuss about State Bugs.

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.

Merging of Equivalent States

4. Explain equivalent states with example.

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.

Merging of Equivalent States


Recognizing Equivalent States

❖ Equivalent states can be recognized by the following procedure.


1. The two states are differentiated only by the different input values. For example
Consider the following figure.
d/y

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.

Explain. Transition Bugs:

The connectivity between two or more states is known as transition


The bug in transition is called Transition Bug.
1. Unspecified and Contradictory Transitions:
• A transition is specified between states. If a transition may occur between states
and not specified (i.e. unspecified transition) then the transition bug occurs.
• If a transition is not possible in the state then there must be a method that
prevents the occurrence of input in that state.
Example
The following example shows how to convert a specification into a state graph and how
contradictions can come out
OK

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

6. Explain the principle and limitations 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.
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.

The starting point of state testing is:


• Define a set of covering input sequences that get back to the initial state when starting
from the initial state.
• For each step in each input sequence, define the expected next state, the expected
transition, and the expected output code.
A set of tests, then, consists of three sets of sequences:
• Input sequences.
• Corresponding transitions or next-state names.
• Output sequences.
Limitations and Extensions

• 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:

• State testing is useful when error corrections are less expensive


• State testing is also useful when the tester wants to detect a specified inputs or when the
order of the input sequence is important
• State testing is specially designed for catching deep bugs.

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.

Limitations and Extensions

• 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.

8. Explain software implementation issues in state testing.

Implementation and Operation


There are four tables involved:
⚫ 1. A table or process that encodes the input values into a compact list (INPUT_CODE_TABLE).
⚫ 2. A table that specifies the next state for every combination of state and input code
(TRANSITION_TABLE).
⚫ 3. A table or case statement that specifies the output or output code, if any, associated with
every state-input combination (OUTPUT_TABLE).
⚫ 4. A table that stores the present state of every device or process that uses the same state
table—e.g., one entry per tape transport (DEVICE_TABLE).
The routine operates as follows, where # means concatenation:
BEGIN
PRESENT_STATE := DEVICE_TABLE(DEVICE_NAME)
ACCEPT INPUT_VALUE
INPUT_CODE := INPUT_CODE_TABLE(INPUT_VALUE)
POINTER := INPUT_CODE#PRESENT STATE
NEW_STATE := TRANSITION_TABLE(POINTER)
OUTPUT_CODE := OUTPUT_TABLE(POINTER)
CALL OUTPUT_HANDLER(OUTPUT_CODE)
DEVICE_TABLE(DEVICE_NAME) := NEW_STATE
END
1. The present state is fetched from memory.
2. The present input value is fetched. If it is already numerical, it can be used directly; otherwise, it
may have to be encoded into a numerical value, say by use of a case statement, a table, or some
other process.
3. The present state and the input code are combined (e.g., concatenated) to yield a pointer (row
and column) of the transition table and its logical image (the output table).
4. The output table, either directly or via a case statement, contains a pointer to the routine to be
executed (the output) for that state-input combination. The routine is invoked (possibly a trivial
routine if no output is required).
5. The same pointer is used to fetch the new state value, which is then stored

Input Encoding and Input Alphabet


⚫ The alternative to input encoding is a huge state graph and table because there must be one
outlink in every state for every possible different input.
⚫ Input encoding compresses the cases and therefore the state graph.
Output Encoding and Output Alphabet
⚫ There are only a finite number of such distinct actions, which we can encode into a
convenient output alphabet.
State Codes and State-Symbol Products
⚫ The term state-symbol product is used to mean the value obtained by any scheme used to
convert the combined state and input code into a pointer to a compact table without holes.
9. Discuss switches, flags and unachievable paths.

Switches, Flags and unachievable paths :


➢ The functionality of switches and flags are almost similar in the state testing.
➢ Switches or flags are used as essential tool for state testing to test the finite state
machine in every possible state
➢ A flag or switch value is set at the initial process of finite state machine, and then
this value is evaluated and tested.
➢ Depending on its value the specific path is selected to find an easiest way for
testing the finite state machine.
➢ Mostly the switch or flag works on true or false condition

➢ 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.

• Fine state machine is represented by a state graph having a finite number of


states and a finite number of transitions between states
• Finite state machine (FSM) is a functional testing tool and programming testing tool.
• That is it is an essential tool for state testing in order to identify or model the
behavior of software.

Essential and inessential finite state behavior:


➢ To understand an essential and inessential finite state behavior, we need
to know the concept of finite state machines and combinational
machines.
➢ There is a difference between finite state machines and combinational machines
in terms of quality.
➢ In combinational machines a path is chosen depending on the truth values of
predicates.
➢ The predicate truth values are the values which once determined will never
change and always remains constant.
➢ In these machines a path is equivalent to a Boolean algebraic expression over the
predicates
➢ Further more it does not matter in which order the decisions are made.
LONG ANSWERS
UNIT-5

1. Explain graph matrix with examples.

The Matrix of a Graph

• 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.

Some of the things to be observed:

• The size of the matrix equals the number of 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.
• A connection from node i to j does not imply a connection from node j to node i.
• If there are several links between two nodes, then the entry is a sum; the “+” sign denotes
parallel links as usual.
2. Discuss set of all paths in graph matrices.

The set of all paths:


➢ The set of all paths is given by the following infinite series of matrix powers.

∑ Ai = A1+A2+A3+…+A∞
i=1
➢ Let I be an n x n diagonal matrix where n is the number of nodes,
then the above expression becomes

∑ Ai = A(I+A1+A2+A3+…+A∞)
i=1
➢ We know that (A+A) = A
So (A+I)2 = A2 + 2AI + I2 = A2 + 2A + I2 = A2 + A+A + I2= A2+A+I. (Since A + A
= A)

➢ 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

The algorithm for finding set of all paths:


• Express n-2 as a binary number.
• Calculate the successive squares of (A+I) matrix, that is (A+I)2, (A+I)4, (A+I)8,
(A+I)16 and so on.
• Select only the binary powers of (A+I) matrix that correspond to a value 1 in
the binary representation of (n-2).
• The set of all paths of length less than or equal to (n-1) is obtained from the
original matrix as a result of step 3.
For example the set of all paths for 16 nodes is given by

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

4. Explain cyclomatic complexity with example.

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 size of the matrix equals the number of 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.

5. Explain different properties of relations?

Relation

A relation is a property that exists between two objects of interest.


For example,
“Node a is connected to node b” or aRb where “R” means “is connected to”.
“a>=b” or aRb where “R” means greater than or equal”.
A graph consists of set of abstract objects called nodes and a relation R between the nodes.
If aRb, which is to say that a has the relation R to b, it is denoted by a link from a to b.

The different properties of relations are.


Transitive Relations:
❖ A Relation R is transitive if aRb and bRc then aRc.
❖ Examples of transitive relations are: is connected to, is greater than or equal to, is
less than or equal to, is a relative of, etc.
❖ Examples of intransitive relations are: is a friend of, is a neighbor of, etc.

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.

6. Discuss about equivalence relation and partial ordering relation.

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.

Partial Ordering Relations:


• A partial ordering relation satisfies the reflexive, transitive, and antisymmetric
properties.
• A graph which shows partial ordering relation between its nodes is said to
be partial ordered graph. Partial ordered graphs have different properties.
They are
I. loop free,
II. There is at least one maximum element.
III. There is at least one minimum element.
IV. If you reverse all the arrows the resultant graph is also partial ordered.
• The maximum element ‘a’ represents the relation xRa. Similarly, the minimum
element ‘a’, represents a relation aRx. Examples are Trees and loop-free graphs.

7. Explain the power of matrix and product of matrix.

➢ A graph matrix is array representation of nodes. In a graph matrix each row


and each column intersection represents, the relationship between the
respective row nodes and column nodes.
➢ The square of the matrix represents all path segments with two links long.
Similarly the third power represents all path segments with three links long
and so on.
➢ Let A be a matrix whose entries are aij. The set of all paths between any node
i and any node j is given by
• Given a matrix whose entries are aij, the square of that matrix is obtained by replacing every
entrywith
n
• aij=Σ aikakj
k=1

• 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 transpose of (A+I)n is.


1 2 3 4 5 6 7 8
1 1
2 1 1 1
3 1 1 1 1 1 1 1
(A+I)nT = 4 1 1 1 1 1 1 1
5 1 1 1 1 1 1 1
6 1 1 1 1
1 1 1 1
7 1 1 1
8 1

➢ 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)

The final result yields to :


a(bfh*e)*(d + bc + bfh * g)
10. Explain linked list representation of graph with example.

You might also like