finish the greedy algorithm in src/query-opt-ent.py