implements two binary searches in scala