Skip to content

FIUP/Algotests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

algotests

Corpus of Dati e Algoritmi Unipd class tests and exercises since 2014/15.

Open Source Love License

Why is it useful?

We tried to write code easy to understand, so even if you don't know how to write code, you can browse the solutions and see how the algorithm works. For example

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

is the optimal algorithm to check if the array is a max-heap.

Questions and issues

The Github issue tracker is only for bug reports and feature requests. Anything else, such as questions for help, should be posted as pull request with detailed motivation.

Team

FIUP

Wanna join? Why not? Checkout our github page, drop an email or follow us on Facebook!

License

Apache License Version 2.0, January 2004