- 
                Notifications
    You must be signed in to change notification settings 
- Fork 314
TreeNode check added for heap.py #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
1abbf2c
              688ee21
              3a755fa
              a6265e9
              5c1c6ac
              192b0d6
              8801c9e
              1718d7a
              7ed4cb1
              cd18a9a
              d9cbefd
              41b20f0
              7d87af0
              d7c25a7
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -64,3 +64,4 @@ __pycache__/ | |
| .idea/ | ||
| build/ | ||
| dist/ | ||
| venv/ | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -29,8 +29,6 @@ def test_BinaryHeap(): | |
| assert max_heap.extract().key == 100 | ||
|  | ||
| expected_sorted_elements = [36, 25, 19, 17, 7, 3, 2, 1] | ||
| l = max_heap.heap[0].left | ||
| l = max_heap.heap[0].right | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might have accidentally removed them. It was showing a warning if I remember correctly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the first line can be removed safely, though do it in a different PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable is never being used, so idk whats the point of having it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, feel free to remove it in a separate PR. | ||
| sorted_elements = [] | ||
| for _ in range(8): | ||
| sorted_elements.append(max_heap.extract().key) | ||
|  | @@ -48,6 +46,15 @@ def test_BinaryHeap(): | |
| sorted_elements = [min_heap.extract().key for _ in range(8)] | ||
| assert expected_sorted_elements == sorted_elements | ||
|  | ||
| #To test ValueError on non TreeNode list | ||
|         
                  HarsheetKakar marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| non_TreeNode_elements = [ | ||
| (7, 7), TreeNode(25, 25), TreeNode(100, 100), | ||
| TreeNode(1, 1), (2, 2), TreeNode(3, 3), | ||
| TreeNode(17, 17), TreeNode(19, 19), TreeNode(36, 36) | ||
| ] | ||
| assert raises(TypeError, lambda: | ||
| BinaryHeap(elements = non_TreeNode_elements, heap_property='min')) | ||
|  | ||
|         
                  HarsheetKakar marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| def test_TernaryHeap(): | ||
| max_heap = TernaryHeap(heap_property="max") | ||
| assert max_heap.extract() is None | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.