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月