Skip to content

Commit 0d3570c

Browse files
committed
Try to fix BinarySearch.scala
1 parent e71ecf8 commit 0d3570c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/scala/BinarySearch.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ def binarySearch(data: Seq[Int], target: Int): Option[Int] = {
44

55
@tailrec
66
def search(left: Int, right: Int): Option[Int] = {
7+
78
if (left > right) None
89
else {
910
val middle: Int = (left + right) / 2
@@ -17,6 +18,7 @@ def binarySearch(data: Seq[Int], target: Int): Option[Int] = {
1718
}
1819

1920
object Main extends App {
21+
2022
val data: Seq[Int] = Seq(0, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12)
2123
val value: Int = 11
2224
println(s"Value '$value' found in position '${binarySearch(data, value).get}'")

0 commit comments

Comments
 (0)