assertlinear_search_recursive(lst_test,target)==(targetinlst_test),"Fout: linear_search_recursive({}, {}) geeft {} in plaats van {}".format(lst_test,target,linear_search_recursive(lst_test,target),targetinlst_test)
outcome=linear_search_recursive(lst_test,target)
assertoutcome==(targetinlst_test), \
f"Fout: linear_search_recursive({lst_test}, {target}) geeft {outcome} in plaats van {target in lst_test}"
deftest_binary_search_recursive():
foriinrange(10):
lst_test=sorted(random.sample(range(20),10))
lst_test=sorted(random.sample(range(20),6))
target=random.randrange(20)
assertbinary_search_recursive(lst_test,target)==(targetinlst_test),"Fout: binary_search_recursive({}, {}) geeft {} in plaats van {}".format(lst_test,target,binary_search_recursive(lst_test,target),targetinlst_test)
outcome=binary_search_recursive(lst_test,target)
assertoutcome==(targetinlst_test), \
f"Fout: binary_search_recursive({lst_test}, {target}) geeft {outcome} in plaats van {target in lst_test}"
if__name__=='__main__':
@ -158,4 +164,5 @@ if __name__ == '__main__':
print("\nGefeliciteerd, alles lijkt te werken! Lever je werk nu in op Canvas...")