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 Issueトラッカーは、バグレポートと機能リクエストのみです。助けのための質問など、その他はすべて、詳細な動機付けのpull requestとして投稿する必要があります。
参加したいですか?なぜだめですか? GitHubページをチェックアウトしたり、メールをドロップしたり、Facebookでフォローしてください!
Apacheライセンスバージョン2.0、2004年1月