implemented the adaptive algorithm using an approximate algorithm