This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bubble_sort(arr): | |
is_sorted = False | |
while not is_sorted: | |
is_sorted = True | |
for i in range(0, len(arr) -1): | |
if arr[i] > arr[i+1]: | |
is_sorted = False | |
arr[i], arr[i+1] = arr[i+1], arr[i] | |
return arr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def linear_search(item, list): | |
for i in list: | |
if i == item: | |
return True | |
return False | |
print(linear_search(4, [1, 2, 4, 4, 5])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary_search(item, arr): | |
def _binary_search(item, first, last, arr): | |
if last < first: | |
return False | |
if last == first: | |
return arr[last] == item | |
mid = (first + last) // 2 | |
if arr[mid] > item: | |
last = mid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import locust | |
import gevent | |
from gevent.socket import socket | |
from gevent.queue import Queue | |
import time | |
from utils.bootstrap import test_conf as TEST_CONFIG | |
import insight |