test_basic_data_structures.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:AlgorithmicToolbox 作者: chaicko 项目源码 文件源码
def test_worst_case(self):
        sys.setrecursionlimit(10 ** 7)  # max depth of recursion
        resource.setrlimit(resource.RLIMIT_STACK,
                           (resource.RLIM_INFINITY, resource.RLIM_INFINITY))
        #  Worst case is a tree with one child per node, that is, a list
        test_input = [-1 if x == 0 else x - 1 for x in range(10 ** 5)]
        tree = tree_height.TreeHeight(len(test_input), test_input)
        assert len(test_input) == tree.compute_height()

        # def test_provided_input_data(self):
        #     files_wildcard = os.path.dirname(__file__) + "/tree_height_test_input/*"
        #     files = glob.glob(files_wildcard)
        #     for file in files:
        #         with open(file) as f:
        #             size = f.readline()
        #             parent = f.readline()
        #             test_input = [int(x) for x in parent.split()]
        #             tree = tree_height.TreeHeight(len(test_input), test_input)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号