P-Tree Algorithm