随笔分类 -  算法

摘要:Python3 示例: def findSmallest(arr): smallest = arr[0] smallest_index = 0 for i in range(1, len(arr)): if arr[i] < smallest: smallest = arr[i] smallest_ 阅读全文
posted @ 2021-10-18 12:04 龙虚度 阅读(28) 评论(0) 推荐(0) 编辑
摘要:二分查找法每次都排查一半的数字,包含则返回其位置,否则返回null。二分查找法的元素列表必须是有序的。 Python 2 示例: def binary_search(list, item): low = 0 high = len(list)-1 while low <= high: mid = (l 阅读全文
posted @ 2021-09-28 20:31 龙虚度 阅读(119) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示