The Wayback Machine - https://web.archive.org/web/20210831161619/https://github.com/TheAlgorithms/Python/pull/4267
Skip to content
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

Wavelet tree #4267

Merged
merged 29 commits into from Jun 8, 2021
Merged

Wavelet tree #4267

merged 29 commits into from Jun 8, 2021

Conversation

@anirudnits
Copy link
Contributor

@anirudnits anirudnits commented Mar 14, 2021

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
Copy link

@algorithms-keeper algorithms-keeper bot left a 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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.



class Node:
def __init__(self, n):

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide descriptive name for the parameter: n

Please provide type hint for the parameter: n

self.left: Optional[Node] = None
self.right: Optional[Node] = None

def __repr__(self):

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function __repr__

Please provide return type hint for the function: __repr__. If the function does not return a value, please provide the type hint as: def function() -> None:

data_structures/binary_tree/wavelet_tree.py Outdated Show resolved Hide resolved
return root


def rank_from_start(node: Node, num: int, i: int) -> int:

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function rank_from_start

Please provide descriptive name for the parameter: i

return rank_from_start(node.right, num, i - node.map_left[i])


def rank(node: Node, num: int, i: int, j: int) -> int:

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function rank

Please provide descriptive name for the parameter: i

Please provide descriptive name for the parameter: j

return rank_till_j - rank_before_i


def quantile(node: Node, k: int, i: int, j: int) -> int:

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function quantile

Please provide descriptive name for the parameter: k

Please provide descriptive name for the parameter: i

Please provide descriptive name for the parameter: j

)


def range_counting(node: Node, i: int, j: int, x: int, y: int) -> int:

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function range_counting

Please provide descriptive name for the parameter: i

Please provide descriptive name for the parameter: j

Please provide descriptive name for the parameter: x

Please provide descriptive name for the parameter: y

return left + right


def main():

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

Please provide return type hint for the function: main. If the function does not return a value, please provide the type hint as: def function() -> None:

Copy link

@algorithms-keeper algorithms-keeper bot left a 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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.



class Node:
def __init__(self, length):

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: length

self.left: Optional[Node] = None
self.right: Optional[Node] = None

def __repr__(self):

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function __repr__

Please provide return type hint for the function: __repr__. If the function does not return a value, please provide the type hint as: def function() -> None:

data_structures/binary_tree/wavelet_tree.py Outdated Show resolved Hide resolved
return root


def rank_from_start(node: Node, num: int, index: int) -> int:

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function rank_from_start

return rank_till_end - rank_before_start


def quantile(node: Node, k: int, start: int, end: int) -> int:

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function quantile

Please provide descriptive name for the parameter: k

)


def range_counting(node: Node, start: int, end: int, x: int, y: int) -> int:

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function range_counting

Please provide descriptive name for the parameter: x

Please provide descriptive name for the parameter: y

Copy link

@algorithms-keeper algorithms-keeper bot left a 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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

data_structures/binary_tree/wavelet_tree.py Outdated Show resolved Hide resolved
return root


def rank_from_start(node: Node, num: int, index: int) -> int:

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 14, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function rank_from_start

Add doctests to placate the algorithm-bot, thanks to @cclauss.

Co-authored-by: Christian Clauss <cclauss@me.com>
Copy link

@algorithms-keeper algorithms-keeper bot left a 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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

data_structures/binary_tree/wavelet_tree.py Outdated Show resolved Hide resolved
return root


def rank_from_start(node: Node, num: int, index: int) -> int:

This comment has been minimized.

@algorithms-keeper

algorithms-keeper bot Mar 27, 2021

As there is no test file in this pull request nor any test function or class in the file data_structures/binary_tree/wavelet_tree.py, please provide doctest for the function rank_from_start

@cclauss
Copy link
Member

@cclauss cclauss commented Apr 7, 2021

Let's get a review from @dhruvmanila first...

@dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Apr 7, 2021

Thanks for the heads up! I will take a look at it today.

@anirudnits
Copy link
Contributor Author

@anirudnits anirudnits commented Apr 24, 2021

Just following up for any updates on this.

@anirudnits
Copy link
Contributor Author

@anirudnits anirudnits commented May 29, 2021

Just following up for any updates.

@anirudnits
Copy link
Contributor Author

@anirudnits anirudnits commented Jun 8, 2021

@cclauss @dhruvmanila just following up for any updates on this PR.

@cclauss
Copy link
Member

@cclauss cclauss commented Jun 8, 2021

Close and reopen to rebase…

@cclauss cclauss closed this Jun 8, 2021
@cclauss cclauss reopened this Jun 8, 2021
@cclauss
cclauss approved these changes Jun 8, 2021
@cclauss cclauss merged commit b743e44 into TheAlgorithms:master Jun 8, 2021
4 checks passed
4 checks passed
@github-actions
project-euler
Details
@github-actions
build
Details
@github-actions
pre-commit
Details
@github-actions
validate-solutions
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants