Saturday, October 6, 2012

Loop invariant


In computer science, a loop invariant is an invariant used to prove properties of loops. Informally, a loop invariant is a statement of the conditions that should be true on entry into a loop and that are guaranteed to remain true on every iteration of the loop. This means that on exit from the loop both the loop invariant and the loop termination condition can be guaranteed.
http://en.wikipedia.org/wiki/Loop_invariant

An algorithm's real-time readiness ratio (RTR)


real-time ratio=average-case running time / worst-case running time


bubblesortheapsortinsertionmergesortquicksort
bestnnlognnnlognnlogn
averagen^2 nlognn^2 nlognnlogn
worstn^2 nlognn^2 nlognn^2

http://www.youtube.com/watch?v=WRekXblcQn8&feature=relmfu

directed acyclic graph (DAG)



  • Directed Acyclic Graphs

A directed acyclic graph (DAG) is a directed graph that contains no cycles
http://www.csse.monash.edu/~lloyd/tildeAlgDS/Graph/DAG/

In mathematics and computer science, a directed acyclic graph is a directed graph with no directed cycles
it is formed by a collection of vertices and directed edges, each edge connecting one vertex to another, such that there is no way to start at some vertex v and follow a sequence of edges that eventually loops back to v again

A collection of tasks that must be ordered into a sequence, subject to constraints that certain tasks must be performed earlier than others, may be represented as a DAG with a vertex for each task and an edge for each constraint

algorithms for topological ordering may be used to generate a valid sequence.

http://en.wikipedia.org/wiki/Directed_acyclic_graph




  • A Model to Represent Directed Acyclic Graphs (DAG) on SQL Databases


In short, DAGs have the following properties:

A DAG has directed edges, i.e. the links that connect vertices (nodes) on the graph have a direction. The direction is denoted by an arrow head.
Starting from an arbitrary vertex, if we traverse the vertices in the direction of the arrows, it is not possible to return back to the originating vertex.

A notable and familiar structure that has the above properties is the inheritance hierarchy in Object-Oriented Programming
http://www.codeproject.com/Articles/22824/A-Model-to-Represent-Directed-Acyclic-Graphs-DAG-o