C-Plus-Plus icon indicating copy to clipboard operation
C-Plus-Plus copied to clipboard

feat: use smart pointer in binary search tree

Open arjunjain8887 opened this issue 1 year ago • 1 comments

  1. Memory Management: Used std::unique_ptr for automatic memory management, reducing the risk of memory leaks.

  2. STL Utilization: Replaced the custom queue implementation with std::queue, simplifying breadth-first traversal.

  3. Code Structure: Organized the code into a BinaryTree class, encapsulating the tree functionality and providing clearer interfaces for operations.

  4. Redundancy Reduction: Combined logic for finding and removing nodes to reduce redundancy, improving readability and maintainability.

  5. Error Handling: Added checks to handle cases where nodes may not be present during removal and traversal.

Description of Change

Checklist

  • [ ] Added description of change
  • [ ] Added file name matches File name guidelines
  • [ ] Added tests and example, test must pass
  • [ ] Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • [ ] Relevant documentation/comments is changed or added
  • [ ] PR title follows semantic commit guidelines
  • [ ] Search previous suggestions before making a new one, as yours may be a duplicate.
  • [ ] I acknowledge that all my contributions will be made under the project's license.

Notes:

arjunjain8887 avatar Sep 27 '24 05:09 arjunjain8887