Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Structures and Algorithms

Similar presentations


Presentation on theme: "Data Structures and Algorithms"— Presentation transcript:

1 Data Structures and Algorithms
Equivalence Classes PLSD210(ii)

2 Lectures 17 - Key Points Graphs Collections of vertices and edges
Paths Spanning Trees Provide a path from any vertex to any other vertex

3 Lecture 17 - Key Points Minimum Spanning Tree
Spanning Tree of minimum cost Cost measure may be anything! Operation All vertices into single element trees, Sort edges, Add next cheapest edge unless it forms a cycle Finish when we’ve added |V|-1 edges Greedy algorithms Don’t look ahead .. Make a “naive” choice at every step

4 Lecture 17 - Key Points Greedy algorithms
Don’t look ahead .. Make a “naive” choice at every step Sometimes difficult to prove Usually proof by contradiction employed Completes classes of efficient algorithms Divide and Conquer Dynamic Greedy

5 Equivalence Classes Cycle Determination in MST Program verification
Relies on Union Find structure Lists pointing to a representative Vertices are partitioned into equivalence classes Equivalence relation: a path connects them Edge creates a cycle if both its end-points have the same representative are in the same equivalence class Program verification Partition input data into equivalence classes Relation: processed in the same way

6 Equivalence Classes Program verification
Partition input data into equivalence classes Relation: processed in the same way Choose a representative of the class Testing the representative Testing all inputs in the same class Experienced Software Engineeers Include special values also Boundaries Identities - 0 and 1 Never choose boundaries, identities, etc as a representative

7 Equivalence Classes Program verification
Experienced Software Engineeers Include special values also Boundaries Identities - 0 and 1 Never choose boundaries, identities, etc as a representative Even though this might be formally OK!

8 Equivalence Classes Program verification Assignment 4 Don’t forget
Identify equivalence classes of function to be tested Set up a program to apply a representative of each class to the function Table or file driven input best Don’t forget Nulls Specification should tell you what will happen on empty or degenerate data sets Empty lists, single node graphs, etc. Illegal input Violates pre-conditions Should raise assertions!

9 Equivalence Classes Program verification Don’t forget Nulls
Specification should tell you what will happen on empty or degenerate data sets Empty lists, single node graphs, etc. Illegal input Violates pre-conditions Should raise assertions!


Download ppt "Data Structures and Algorithms"

Similar presentations


Ads by Google