Skip to content

Conversation

@RoshanSai07
Copy link

This PR adds a Binary Search Tree (BST) implementation in Java under the Trees category, along with comprehensive JUnit 5 tests.

Changes included:

BinarySearchTree.java

  • Core operations: insert, delete, search
  • Traversals: inorder, preorder, postorder (print)
  • Utility functions: findMin(), findMax()
  • Traversal methods returning List for testing: inorderList(), preorderList(), postorderList()
  • Fully documented with JavaDoc-style comments

BinarySearchTreeTest.java

  • Tests insertion, deletion (leaf, one child, two children), search
  • Tests findMin and findMax
  • Tests inorder, preorder, postorder traversals
  • Matches repo style and JUnit 5 conventions

This addition improves the Trees section in the repository, providing a fundamental data structure for search, indexing, and interview/competitive programming applications.

References:
Feature request issue: Closes Status: #6957

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 66.00000% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.20%. Comparing base (a4cf6e3) to head (ced31be).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
.../java/com/thealgorithms/tree/BinarySearchTree.java 66.00% 28 Missing and 6 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6959      +/-   ##
============================================
- Coverage     78.26%   78.20%   -0.07%     
- Complexity     6567     6597      +30     
============================================
  Files           743      744       +1     
  Lines         21886    21986     +100     
  Branches       4284     4293       +9     
============================================
+ Hits          17129    17194      +65     
- Misses         4074     4102      +28     
- Partials        683      690       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants