Skip to main content

Posts

C++ implementation of quick sort using std::list

An C++ implementation of quick sort using std::list. The code is as follow: #include using namespace std; typedef list ::iterator ITER; void quicksort(list * seq, ITER middle, ITER end){ ITER iter = end; ITER begin = middle; if(middle == end) { return; } else{ --iter; } ITER temp; while(iter != middle){ if(*iter temp = iter; --iter; begin = seq->insert(begin,*temp); seq->erase(temp); } else{ --iter; } } quicksort(seq,begin,middle); quicksort(seq,++middle,end); }

Pseudocode of Teiresias algorithm

//the candidate stack Stack S; //check if P is prefix less than Q //P=AC..T and Q=T.G, P is prefix less than Q. //P=AC..TA and Q=AC..T, P is prefix less than Q. bool PrefixLess(P,Q); //check if P is suffix less than Q //P=AC..T and Q=AC.GT, Q is suffix less than P. //P=C.GT and Q=AC.GT, Q is suffix less than P. bool SuffixLess(P,Q); //check if P and Q are convolutable bool isConvolutable(P,Q); //convolute P and Q Sequence Convolute(P,Q); //check from the result list, judge if P is maximal bool isMaximal(P); //add P to result list bool AddToResultList(P); Teiresias(){ P=S.top(); for Q=S.Location(P).next() to S.bottom(){ if isConvolutable(P,Q){ R=Convolute(P,Q); S.push(R); Teiresias(); } } for Q=S.Location(P).next() to S.bottom(){ if isConvolutable(Q,P){ R=Convolute(Q,P); S.push(R); Teiresias(); } } if isMaximal(P){ AddToResultList(P); } }

Notes on Sequential Pattern Mining (2) -- Partial Order Pattern Mining and Contrast Mining

1. In , the authors induce TEIRESIAS algorithms to mining combinatorial patterns with gap constraints in biological sequences. The patterns TEIRESIAS mined is similiar with the common sequential patterns, but it could contain "." the wild card which is also in the alphbel of the sequences database standing for any other item available, for example pattern "A..B" is a length-4 pattern, with two arbitrary items between the first A and the last B. Patterns "AC.B", "AADB" are all said to be more specific than pattern "A..B". TEIRESIAS mining all the maximal patterns () with a support over a min threshold K. There some key points of TEIRESIAS algorithms: 1)The growth of the patterns The growth of the patterns is accomplished by convolute current pattern by a short length pattern. Pattern A and pattern B are convolutable if the last L(very small) characters of pattern A is the same as the first L characters of pattern B, then ...

ns-2 2.30 on Fedora Core 6(FC6)

The allinone package of the network simulator ns-2 2.30 whish is newly release on sep 24, 2006 could be installed on Fedora Core 6 easily, and work very well on it. There are a lot of problem about the installation of ns-2 on ubuntu and previous fedora core editions.

Notes on algorithms(2) -- Principles of Dynamic Programming

Dynamic Programming is to convert a problem into a polynomial time algorithm by storing some of the middle results first. This is to avoid searching some redundant spaces in the problem. In the book (J.K. and E.T.), the following 3 are the rules of dynamic programming: 1) There are only a polynomial number of subproblems. 2) The solution to the original problem can be easily computed from the solutions to the subproblems. 3) There is a natural ordering on subproblems from "seallest" to "largest".

Notes on algorithms(1) -- Finding Patterns in a File -- An example on Parallelized Programming

Notes on (Gregory R. Andrews). The problem is to find a string pattern in a file, and print lines containing the patterns. The Sequential program of the problem is as below: string line; read a line of input from stdin into line; while(!EOF){ look for pattern in line; if (pattern is in line) write line; read next line of input; } The point we can parallelize is inside the while loop, the pattern-finding step and the line-reading step. But here we use the same variable line, and we must eliminate it. So here we induces a variable line2 to perform the reading operation, and variable line1 to perform the finding operation, another variable buffer is to communicate between line1 and line2. The program is as below: string buffer; bool done = false; co #process 1 string line1; while (true){ wait for buffer to be full or done to be true; if (done) break; line1 = buffer; signal that buffer is empty; look for pattern in line1; if (pattern is in line1) write line1; } //#process 2 string line2; w...

Notes on Knowledge Representation

1.Intruduction The paper (John Molopoulos,1981) is a brief overview of terminology and related issues on knowledge representation. Knowledge Representation is a central problem in Artificial Intelligence (AI) today. Its importance stems from the fact that the current design paradigm for "intelligent" systems stresses the need for expert knowledge in the system along with associated knowledge-handling facilities. The basic problem of KR is the development of a sufficiently precise notation for representing knowledge. We shall refer to any such notation as a (knowledge) representation scheme. Using such a scheme one can specify a knowledge base consisting of facts. 2.A Taxonomy of Representation Schemes Representation schemes have been classified into declarative and procedural ones . The paper subdivide declarative schemes into logical and (semantic) network ones. 2.1 Logical Representation schemes is such schemes employ the notions of constant, variable, function, predicate, ...