Add merge sort for linked list#14712
Conversation
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| from data_structures.linked_list.singly_linked_list import Node | ||
|
|
||
|
|
||
| def split_middle(node: Node) -> tuple[Node | None, Node | None]: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_structures/linked_list/merge_sort_linked_list.py, please provide doctest for the function split_middle
There was a problem hiding this comment.
Added doctests for split_middle, along with a test function in the file.
| return previous, slow | ||
|
|
||
|
|
||
| def sort_list(head: Node | None) -> Node | None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_structures/linked_list/merge_sort_linked_list.py, please provide doctest for the function sort_list
There was a problem hiding this comment.
Added doctests for sort_list, along with a test function in the file.
Describe your change:
This pull request adds a merge sort implementation for a singly linked list in
data_structures/linked_list/merge_sort_linked_list.py.The implementation includes:
Checklist: