









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Most real world computer applications deal with vast amounts of data. Searching for a particular data item can take a lot of computer time, or a small amount of computer time, depending on the algorithm used.
If a list of 1000 data items needs to be searched for some key value, in the worst case it will take 1000 comparisons. What do we mean by the worst case? The worst case is the case when the key value is the last in the list or the key value is not found in the list. A collection of data items stored in a computer in a sequential contiguous list is called an array.
What is my algorithm?
The answer lies in how many times we can cut an array, or list, in half. We can cut a number n in half, log 2 n times. As n grows, the log of n grows very slowly.
Sometime the “sorting” of a list of data is not unique. That’s right! You can get one ordering and your neighbor can get another. This occurs when a data value must precede some other data values but does not have a specific position. Many real world jobs require tasks that behave this way. Example: building a house, dressing a baby, scheduling your classes.
Ex. Dressing Baby diaper must precede undershirt, dress, coat socks must precede shoes undershirt must precede dress hat can be put on anytime undershirt and dress must precede coat
7 ordered pairs: (2,3) (2,7) (2,6) (4,5) (7,6) (3,7) (3,6) (that is just a coincidence !!!!) We have 7 tasks: 1,2,3,4,5,6,7 and A topological sort is a listing of the order in which these tasks can be performed. For example: 4,5,1,2,3,7, Is this the only topological sort that will get the job done? No. Find another.
A topological sort is easy to find using a graph. View the “Topological Sort” power point presentation on our website. What is the algorithm used to find a topological sort in the presentation? 1: Draw a node for each task. 2: Connect tasks with arrows that indicate precedence. 3: Delete a node that has no successor.