CS Algorithm