CARVIEW |
Select Language
HTTP/2 200
date: Tue, 14 Oct 2025 19:47:47 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=3259ec46ea270e85cf2b377f4be09c3771ccae9fc9b05df9b9c627f0aaf4f895a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22WvtMoBDEU_d6iG9Pn_aG8Wvxecx91XAK%22%3B%7D; HttpOnly; Path=/
cf-ray: 98e9972b3a27165e-BLR
Binary search - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- array = list(range(1000000))
- # array.index(2)
- # 4 function calls in 0.065 seconds
- def get_binary_index(array, element):
- l = 0
- r = len(array) - 1
- while l <= r:
- m = (l + r) // 2
- if array[m] == element:
- return m
- if array[m] < element:
- l = m + 1
- else:
- if array[m] > element:
- r = m - 1
- return -1
- # get_binary_index(array, 2)
- # 5 function calls in 0.062 seconds
- def binary_search(array, number):
- array_length = len(array)
- min_index = 0
- max_index = array_length - 1
- current_index = array_length // 2
- while True:
- if array[current_index] == number:
- return(current_index)
- break
- if array[current_index] > number:
- max_index = current_index
- current_index = (max_index - min_index) // 2
- continue
- if array[current_index] < number:
- min_index = current_index
- current_index += (max_index - min_index) // 2 + (max_index - min_index) % 2
- else:
- return(-1)
- # binary_search(array, 2)
- # 5 function calls in 0.062 seconds
Advertisement
Add Comment
Please, Sign In to add comment
-
🚀 Swapzone +37% glitch
JavaScript | 6 sec ago | 0.24 KB
-
💎 ChangeNOW Exploit
JavaScript | 15 sec ago | 0.24 KB
-
💡 EASY MONEY GUIDE ✅ Working
JavaScript | 24 sec ago | 0.24 KB
-
⚡ Crypto Swap Glitch ✅ Working ⚡
JavaScript | 33 sec ago | 0.24 KB
-
💵 Make 3000$ in 20 minutes 💵
JavaScript | 42 sec ago | 0.24 KB
-
🔥 Exchange profit method
JavaScript | 52 sec ago | 0.24 KB
-
🚨 Free Crypto Method 🚨
JavaScript | 1 min ago | 0.24 KB
-
💡 Instant BTC Profit Method ✅ Working
JavaScript | 1 min ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand