implementations of weighted algorithms