Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bS(a:List[Int], lookingFor:Int) {
- var start=0
- var end=a.length
- var mid=(start+end)/2
- while(a(mid)!=lookingFor && start >= end) {
- if(lookingFor < a(mid)) end =mid
- else start=mid+1
- mid=(start+end)/2
- }
- if(a(mid)==lookingFor) mid else -1
- }
- val xs = 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: Nil
- if(bS(xs,3)==(-1)) println("hehe")
Advertisement