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

[FEATURE REQUEST] Add Treap class in java #5547

Open
ShreeHarish opened this issue Oct 3, 2024 · 3 comments
Open

[FEATURE REQUEST] Add Treap class in java #5547

ShreeHarish opened this issue Oct 3, 2024 · 3 comments

Comments

@ShreeHarish
Copy link
Contributor

What would you like to Propose?

What would I like to propose?

A treap (short for "tree heap") is a type of balanced binary search tree that combines properties of both a binary search tree and a heap. It ensures that the tree remains balanced during operations like insertion and deletion, achieving good average-case time complexities for these operations.

Issue details

Issue details

The repository currently lacks implementation of Treap`

Additional Information

No response

@SaxenaPrashast
Copy link

Title:

"Add Treap Data Structure to the Repository"

Description:

I would like to propose the addition of the Treap (Tree Heap) data structure to the repository. A Treap is a randomized binary search tree that maintains the binary search tree property on the keys and a heap property on random priorities assigned to each node. This ensures that the tree remains balanced with an average-case time complexity of O(log n) for insertion, deletion, and search operations.

Why It’s Needed:

Currently, the repository does not include an implementation of a self-balancing binary search tree like a Treap. This data structure can be useful in situations where efficient insertion, deletion, and search operations are needed while keeping the structure simple and randomized, avoiding the complexity of manually balancing trees (e.g., AVL or Red-Black Trees).

Proposed Features:

  1. Insert: Add a node by maintaining both the binary search tree and heap properties.
  2. Delete: Remove a node while maintaining both properties.
  3. Search: Perform standard binary search tree operations for key lookups.

Documentation:

I will provide clear inline comments and documentation explaining the purpose and use of the Treap. This will include examples of how to use the data structure.

@siriak
Copy link
Member

siriak commented Oct 4, 2024

Looks good, let's add it

@ShreeHarish
Copy link
Contributor Author

@siriak I have added a pull request for this #5563. This is also my first time, so kindly ping me for any mods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants