0% found this document useful (0 votes)
23 views38 pages

Unit 3 Part-1

The document discusses path products and expressions in the context of flow graphs, highlighting their purpose and applications in software development, testing, and debugging. It defines key concepts such as path expressions and regular expressions, and outlines the reduction procedure for converting flow graphs into path expressions. Additionally, it covers various algebraic rules and identities related to path products, emphasizing their significance in analyzing program structures.

Uploaded by

rupa reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views38 pages

Unit 3 Part-1

The document discusses path products and expressions in the context of flow graphs, highlighting their purpose and applications in software development, testing, and debugging. It defines key concepts such as path expressions and regular expressions, and outlines the reduction procedure for converting flow graphs into path expressions. Additionally, it covers various algebraic rules and identities related to path products, emphasizing their significance in analyzing program structures.

Uploaded by

rupa reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 38

UNIT-III

Path Products & expressions

E.RUPA

Assistant Professor
1
CSE Department
Path Products & expressions - Purpose
PURPOSE: APPLICATIONS
1. How many paths in a flow-graph?

Maximum, minimum etc.

2. The probability of getting to a point in a program ?

(to a node in a flow graph)

3. The mean processing time of a routine (a flow graph)

4. Effect of Routines involving complementary operations :

(Push / Pop & Get / Return)


2
Path Products & expressions - Purpose
PURPOSE & APPLICATIONS

1. Check for data flow anomalies.

2. Regular expressions are applied to problems in test


design & debugging

3. Electronics engineers use flow graphs to design &


analyze circuits & logic designers.
1. Software development, testing & debugging tools use
flow graph analysis tools & techniques.
1. These are helpful for test tool builders.
3
Path Products & expressions - Motivation
Motivation

1. Flow graph is an abstract representation of a program.

2. A question on a program can be mapped on to an


equivalent question on an appropriate flow graph.

3. It will be a foundation for syntax testing & state testing

4
Path Products & expressions - Definitions

Path Expression:

An algebraic representation of sets of paths in a


flow graph.

Regular Expression:

Path expressions converted by using arithmetic


laws & weights into an algebraic function.

5
Path Products & expressions – Path Product

• Annotate each link with a name.

• The pathname as you traverse a path (segment)


expressed as concatenation of the link names is the
path product.

c
1 2 3 4
a b d

• Examples of path products between 1 & 4 are:

abd abcbd a b c b c b d ….
6
Path Products & expressions – Path Expression
Path Expression
Simply: Derive using path products.

c
1 2 3 4
a b d

Example:

{ a b d , a b c b d, a b c b c b d , ….. }

abd + abcbd + abcbcbd + ….


7
Path Products & expressions – Path Expression
Example:

h i
e f j

a b c d

{ abcd , abfhebcd , abfigebcd , abfijd }

abcd + abfhebcd + abfigebcd + abfijd

8
Path Products & expressions – Path Expression

Path name for two successive path segments is the


concatenation of their path products.

X = abc Y = def XY = abcdef

a X = aabc X a = abca XaX = abcaabc

X = ab + cd Y = ef + gh XY = abef + abgh + cdef +


cdgh

9
Path Products & expressions – Path Segments &
Products
• Loops:

a1 = a a2 = aa a3 = aaa an = aaaaa … n times

X = abc X1 = abc X2 = (abc)2 = abcabc

• Identity element

a0 = 1 X0 = 1 (path of length 0)

10
Path Products & expressions – Path Product

Path Product

• Not Commutative:

XY ≠ YX in general

• Associative

A ( BC ) = ( AB ) C = ABC : Rule 1

11
Path Products & expressions – Path Product

Denotes a set of paths in parallel between two nodes.

• Commutative

X + Y = Y + X : Rule 2

• Associative

(X+Y)+Z = X+(Y+Z) = X+Y+Z : Rule 3

• Distributive

A ( B + C) = A B + A C : Rule 4
(A+B)C = AC+BC
12
Path Products & expressions – Path Products

• Absorption

X + X = X : Rule
5
X + any subset of X = X

X = a + bc + abcd X + a = X + bc + abcd = X

13
Path Products & expressions – Path Products

• Loop:
b
An infinite set of parallel paths.
a c

b* = b0 + b1 + b2 + b3 + ……

X* = X0 + X1 + X2 + X3 + ……

X+ = X1 + X2 + X3 + ……

• X X* = X* X = X+  a a* = a* a = a+

n
X = X0 + X1 + X2 + X3 + …… + Xn
14
Path Products & expressions – Path products
More Rules…

m n
X + X = Xn if n ≥ m : Rule 6
= Xm if n < m

m n
X X = Xm+n : Rule 7

X X* = X*
n n
= X* X : Rule 8

X X+ = X+
n n
= X+ X : Rule 9 15
Path Products & expressions – Path products
Identity Elements ..
1 : Path of Zero Length

1+1 = 1 : Rule 11

1X = X1 = X : Rule
12

1* = 1 +
n n
1 = 1 = = 1 : Rule
13
16

+
Path Products & expressions – Path products
Identity Elements ..

0 : empty set of paths

X + 0 = 0+X = X : Rule 15

X0 = 0X = 0 : Rule 16

0* = 1 + 0 + 0 2 + 03 + . . . = 1 : Rule 17

17
Path Products & expressions – Reduction Procedure

 To convert a flow graph into a path expression that


denotes the set of all entry/exit paths.

 Node by Node Reduction Procedure

18
Path Products & expressions – Reduction Procedure
Initialization Steps:

1. Combine all serial links by multiplying their path


expressions.

1. Combine all parallel links by adding their path


expressions.

1. Remove all self-loops - replace with links of the


form X*
19
Path Products & expressions – Reduction Procedure
Steps in the Algorithm’s loop

4. Select a non-initial & non-final node .

Replace it with a set of equivalent links, whose path


expressions correspond to all the ways you can form a product
of the set of in-links with the set of out-links of that node.

5
4
d e
f
g
1 a 2 3
b

20
Path Products & expressions – Reduction Procedure
Steps in the Algorithm’s loop:

5. Combine any serial links by multiplying their path expressions.


( as in step 1)

6. Combine any parallel links by adding their path expressions.


( as in step 2)

7. Remove all the self-loops.


( as in step 3)

8. IF there’s just one node between entry & exit nodes, path
expression for the flow graph is the link’s path expression.
ELSE, return to step 4.
21
Path Products & expressions – Reduction Procedure

Path Expression for a Flow Graph

• is not unique

• depends on the order of node removal.

22
Path Products & expressions – Reduction Procedure
Example
Cross-Term Step (Step 4 of the algorithm)

• Fundamental step.

• Removes nodes one by one till there’s one entry & one exit
node.

• Replace the node by path products of all in-links with all out-links
and interconnecting its immediate neighbors.

23
Path Products & expressions – Reduction Procedure
Example
Processing of Loop Terms:

a c a b*c
1 2 1 2

d b*d

24
Path Products & expressions – Reduction Procedure
Example
Processing of Loop Terms:

a b c f
1 2 3 4 5
d
e

bd
a bc f
1 2 4 5

a (bd)* bc f
1 2 4 5

e
25
Path Products & expressions – Reduction Procedure
Example
Processing of Loop Terms:

a (bd)* bc f
1 2 4 5

a (bd)* bc f
1 4 5

e (bd)* bc

a (bd)* bc ( e (bd)* bc ) * f
1 4 5

a (bd)* bc ( e (bd)* bc )* f
26
Path Products & expressions – Reduction Procedure
Example
Example:

a b c d e
1 3 4 5 6 2

f g h i
j k l
7 8 9 10

a b c d e
1 3 4 5 6 2

f g h il
j k
7 8 9

im
27
Path Products & expressions – Reduction Procedure
Example
a b c d e
1 3 4 5 6 2

f g ilh
j kh
7 8

im
a b c d e
1 3 4 5 6 2

g ilh
jf
kh
8

imf
a b c+gkh d e
1 3 4 5 6 2
gif ilh

imf 28
Path Products & expressions – Reduction Procedure
Example
bgif

a b(c+gkh) d e
1 3 5 6 2
ilh
imf

(bgif)*b(c+gkh)
a d e
1 3 5 6 2
ilh
imf
ilhd

a (bgif)*b(c+gkh)d e
1 3 6 2

imf
29
Path Products & expressions – Reduction Procedure
Example
a (bgif)*b(c+gkh)d (ilhd)*e
1 3 6 2

(ilhd)*imf

a(bgif)*b(c+gkh)d (ilhd)*e
1 6 2

(ilhd)*imf(bgif)*b(c+gkh)d

30
Path Products & expressions – Reduction Procedure
Example

a(bgif)*b(c+gkh)d {(ilhd)*imf(bgif)*b(c+gkh)d}* (ilhd)*e


1 6 2

Flow Graph Path Expression :


a(bgif)*b(c+gkh)d {(ilhd)*imf(bgif)*b(c+gkh)d}* (ilhd)*e

31
Path Products & expressions – Before going into
Applications
Before that, we learn:

Identities

Structured Flow Graphs (code/routines)

Unstructured Flow graphs (routines)

32
Path Products & expressions – Identities / Rules
(A+B)* = ( A* + B* ) * :
I1

= ( A* B* )* :
I2

= ( A* B )* A* :
I3

= ( B* A )* B* :
I4

= ( A* B + A )* :
I5

= ( B* A + B )* :
I6

(A+B+C+...)* = ( A* + B* + C* + . . . )* 33:

I7
Path Products & expressions – Structured Flow
Graphs
Reducible to a single link by successive application of the
transformations shown below.

A B A, B
Process

A B A B
IF THEN .. ELSE ..

A B
WHILE .. DO ..
34
Path Products & expressions – Structured Flow
Graphs
Structured flow graph transformations

A B A, B
REPEAT .. UNTIL ..

Properties:
•No cross-term transformation.
•No GOTOs.
•No entry into or exit from the middle of a loop.
35
Path Products & expressions – Structured Flow
Graphs
Some examples:

f
d
b
a b c d e
a c g i
e h
j

36
Path Products & expressions – UNstructured Flow
Graphs
Some examples – unstructured flow graphs/code:

X
Jumping into loops
X
Jumping out of loops

Branching into Decisions Branching out of Decisions


37
Questions from the previous year’s exams

1. Write short notes on: path products, path expressions, path sums,
loops.

2. Define structured code. Explain lower path count Arithmetic.

3. What is the looping probability of a path expression. Write arithmetic


rules. Explain with an example.

4. Write the steps involved in Node Reduction Procedure. Illustrate all


the steps with the help of neatly labeled diagrams.

38

You might also like