divide program to dense and sparse edition