Skip to content

Create binary_trie.py - #11918

Closed
ankan2526 wants to merge 4 commits into
TheAlgorithms:masterfrom
ankan2526:patch-1
Closed

ankan2526 wants to merge 4 commits into
TheAlgorithms:masterfrom
ankan2526:patch-1

Conversation

@ankan2526

Copy link
Copy Markdown

Data Structure for maintaining Binary Trie.

Useful in Competitive Programming.

Contains method to find maximum and minimum XOR value.

Useful in Competitive Programming.

Contains method to find maximum and minimum XOR value.
@algorithms-keeper algorithms-keeper Bot added the tests are failing Do not merge until tests pass label Oct 9, 2024
@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed and removed tests are failing Do not merge until tests pass labels Oct 9, 2024
@algorithms-keeper algorithms-keeper Bot added require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required require type hints https://docs.python.org/3/library/typing.html labels Sep 23, 2026

@algorithms-keeper algorithms-keeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

self.to = [[-1], [-1]]
self.mb = max_bit_len

def add(self, a):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Please provide type hint for the parameter: a

Please provide descriptive name for the parameter: a

u = self.to[d][u]
self.cc[u] += 1

def remove(self, a):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Please provide type hint for the parameter: a

Please provide descriptive name for the parameter: a

self.cc[u] -= 1
return True

def cnt(self, a):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Please provide type hint for the parameter: a

Please provide descriptive name for the parameter: a

return 0
return self.cc[u]

def min_xor(self, a):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Please provide type hint for the parameter: a

Please provide descriptive name for the parameter: a

u = v
return res

def max_xor(self, a):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Please provide type hint for the parameter: a

Please provide descriptive name for the parameter: a

@@ -0,0 +1,71 @@
class BinaryTrie:
def __init__(self, max_bit_len=31):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: max_bit_len

@cclauss

cclauss commented Sep 23, 2026

Copy link
Copy Markdown
Member

No descriptive names, no type hints, no doctests. See CONTRIBUTING.md.

@cclauss cclauss closed this Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required require type hints https://docs.python.org/3/library/typing.html

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants