Algotests
1.0.0
自2014/15年以来, Dati e Algoritmi unipd类测试和练习。
我们尝试编写易于理解的代码,因此,即使您不知道如何编写代码,也可以浏览解决方案并查看算法的工作原理。例如
def is_max_heap(a):
" " "
:param a: list
Array organized as max-heap
:return: bool
Checks if array a is a max-heap
" " "
for i in range(len(a)):
parent = a[i]
if left_child_index(i) in range(len(a)):
l_child = a[left_child_index(i)] # left child of node
else:
l_child = None
if right_child_index(i) in range(len(a)):
r_child = a[right_child_index(i)] # right child of node
else:
r_child = None
if (not check_child(l_child, parent)) or (not check_child(r_child, parent)):
return False
return True是检查阵列是否是最大值的最佳算法。
GitHub问题跟踪器仅用于错误报告和功能请求。其他任何东西,例如寻求帮助的问题,都应以详细的动力将其作为pull request发布。
想加入吗?为什么不呢?请查看我们的GitHub页面,删除电子邮件或在Facebook上关注我们!
Apache许可证版本2.0,2004年1月