ARTS第五周
Algorithm
经典的二分查找算法(python 实现)
!/usr/bin/python3.5 #二分查找算法 def binary_search(list,item): low = 0; high = len(list) - 1 i = 1; while low <= high: print('第',i,'次查找\n') i=i+1 mid = (low + high) // 2 #如果非整数则自动向下取整 guess = list[mid] if guess == item: return mid if guess > item: high = mid else: low = mid if high - low == 1: return '没有找到' print('没找到'); my_list = [1,2,3,4,5,6,7,8,9,10] print(binary_search(my_list, 44)) #输出没有找到 print(binary_search(my_list, 3)) # 输出2
Review
https://medium.com/the-era-of-apis/how-to-use-an-api-with-php-complete-beginners-guide-4283f9f8d9b3
Tips
linux ccat工具命令可以高亮显示代码哦。
Share
https://cnbin.github.io/blog/2016/01/05/er-cha-shu-de-bian-li/
二叉树的遍历DLR LDR LRD
One thought on “ARTS第五周”
thumbs up