DOC PREVIEW
GSU CSC 2510 - ch04s2

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Relations, Functions, and MatricesTopological SortingAlgorithm: Topological SortingExample: Topological SortingSlide 5Example: PERT ChartSlide 7Exercise: PERT ChartRelations, Functions, and MatricesMathematical Structures for Computer ScienceChapter 4Copyright © 2006 W.H. Freeman & Co. MSCS Slides Relations, Functions and MatricesSection 4.2 Topological Sorting 2Topological SortingTopological sorting finds a total ordering  from a partial ordering  on a finite set that is an extension of , meaning that if x  y, then x  y . This is indeed a sorting process in the sense that the objects end up being totally ordered, but since they must be partially ordered to begin with, it is a very specialized sorting process.In a finite partially ordered set, an element is minimal if it has no predecessors. In a finite nonempty partially ordered set, at least one minimal element must exist. To see this, let x belong to the set. If x is not minimal, then there is a y in the set with y  x, y  x. If y is not minimal, then there is a z in the set with z  y, z  y, and so on. Because the set is finite, this process cannot go on indefinitely, so one such element must be minimal. A minimal element in a Hasse diagram has no elements below it.Section 4.2 Topological Sorting 3Algorithm: Topological SortingTopSort(finite set S; partial ordering on S) //find a total ordering on S that is an extension of  Local variable integer i //enumerates tasks in total ordering i = 1 while S =  pick a minimal element xi from S; S = S  {xi} i = i 1 end while //x1 < x2 < x3 < … < xn is now a total ordering of  that extends write(x1, x2, x3, …, xn) end function TopSortSection 4.2 Topological Sorting 4Example: Topological SortingErnie and his brothers run a woodworking shop in the hills of New Hampshire that manufactures rocking chairs with padded cushion seats. The manufacturing process can be broken down into a number of tasks, some of which have certain other tasks as prerequisites. The following table shows the manufacturing tasks for a rocking chair, the prerequisite tasks, and the number of hours required to perform each task.Section 4.2 Topological Sorting 5Example: Topological SortingWe can define a partial ordering on the set of tasks by x  y  task x = task y or task x is a prerequisite to task y. Quite obviously, this relation is reflexive, antisymmetric, and transitive. Also, x  y  task x is a prerequisite to task y.Also, x < y  task x is a prerequisite to task y.In the Hasse diagram for this partial ordering, the nodes are tasks. Add to each node the information about the time to perform the task. Orient the diagram so that, if x < y, then x is to the left of y rather than below y. Thus, the entire diagram runs from left to right rather than from bottom to top. Such a diagram for task scheduling is often called a PERT (program evaluation and review technique) chart.Section 4.2 Topological Sorting 6Example: PERT ChartThe PERT chart for manufacturing rocking chairs is shown below.With task numbers substituted for task names and arrows pointing to a task from its prerequisite task(s). The numbers in parentheses indicate the time required to perform the task.Section 4.2 Topological Sorting 7Example: Topological SortingOne topological sort of the partial ordering of this manufacturing example is 6, 1, 7, 2, 3, 5, 4, 8, 10, 9, 11, 12.In the figure on the previous slide, either 6 or 1 is minimal and may be chosen as the first element. If 6 is chosen and removed from the set, then, as shown in the figure (a), either 1 or 7 is minimal. If 1 is then chosen and removed from the set (figure (b)), then 2, 3, 4, 5, and 7 are all minimal and any one can be chosen next. The process continues until all nodes have been chosen. If Ernie’s brothers all move to the city and he is left to build rocking chairs alone, the topological sort gives an order in which he can perform tasks sequentially.(a) (b)Section 4.2 Topological Sorting 8Exercise: PERT ChartConstruct the PERT chart for building a house from the following task


View Full Document

GSU CSC 2510 - ch04s2

Documents in this Course
ch02s2

ch02s2

5 pages

ch01s6

ch01s6

10 pages

ch01s1

ch01s1

21 pages

ch02s4

ch02s4

10 pages

ch08s2

ch08s2

21 pages

ch08s3

ch08s3

15 pages

ch07s3

ch07s3

21 pages

ch04s3

ch04s3

23 pages

ch06s3

ch06s3

16 pages

ch01s3

ch01s3

15 pages

ch03s4

ch03s4

11 pages

ch03s6

ch03s6

6 pages

ch03s5

ch03s5

9 pages

ch06s2

ch06s2

9 pages

ch03s1

ch03s1

19 pages

ch07s1

ch07s1

11 pages

ch02s1

ch02s1

14 pages

ch08s1

ch08s1

15 pages

ch02s5

ch02s5

9 pages

ch01s4

ch01s4

13 pages

Load more
Download ch04s2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view ch04s2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view ch04s2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?