Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn bsearch [ n, arr ]
- (if (zero? (count arr)) -1
- (let [middle (int (/ (count arr) 2))]
- (println n middle arr)
- (if (= n (nth arr middle))
- middle
- (if (< n (nth arr middle))
- (bsearch n (drop-last middle arr))
- (bsearch n (take-last middle arr))
- )))))
- (println (sort [ 8 4 7 3 9 5 3 0 87 65 43 98 43 ] ))
- (bsearch 65 (sort [ 8 4 7 3 9 5 3 0 87 65 43 98 43 ] ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement