Esempio n. 1
0
    def testHeapify(self):
        # Test that the root node is sorted to the left child
        data = [1, 9, 5]
        Sort._heapify(data, 0, 3)
        self.assertEqual(data, [9, 1, 5])

        # Test that the root node is sorted to the bottom left grand-child
        data = [1, 5, 9, 1, 3, 2]
        Sort._heapify(data, 0, 6)
        self.assertEqual(data, [9, 5, 2, 1, 3, 1])
Esempio n. 2
0
    def testHeapify(self):
        # Test that the root node is sorted to the left child
        data = [1, 9, 5]
        Sort._heapify(data, 0, 3)
        self.assertEqual(data, [9, 1, 5])

        # Test that the root node is sorted to the bottom left grand-child
        data = [1, 5, 9, 1, 3, 2]
        Sort._heapify(data, 0, 6)
        self.assertEqual(data, [9, 5, 2, 1, 3, 1])