Azarias A'Neals AD325 -- Implementing and Testing Binary Search Tree's
To run, open file and right-click on TestBinarySearchTreeMain.
In this assignment, you will implement a Binary Search Tree (BST) in either Python or Java. Additionally, you'll create test cases to verify the correctness of each operation within your BST. This exercise will not only enhance your understanding of BST operations but also emphasize the importance of testing in software development.
Objectives To implement the fundamental operations of a BST: insertion, search, and deletion. To write test cases that validate the functionality and robustness of your BST implementation. To develop skills in debugging and testing within a programming context. Requirements BST Implementation
Your BST should include methods for insertion, search, and deletion of nodes. Implement additional methods to print the tree in an in-order traversal to assist with debugging. Ensure that your implementation handles edge cases such as inserting duplicate values or deleting non-existent nodes. Test Case Development
Create a separate test suite that independently tests each operation of your BST. Include test cases for typical operations as well as edge cases (e.g., deletion of a node with no children, one child, and two children). Test cases should also cover searching for values that do not exist in the tree and inserting into an empty tree. Assignment Tasks Task 1: Implementing the BST
Python Implementation: Define a class TreeNode with attributes for value, left, and right. Define a class BinarySearchTree that initializes an empty tree and includes methods for insertion, search, deletion, and in-order traversal. Java Implementation: Create a class TreeNode with attributes for value, left, and right. Create a class BinarySearchTree with methods to initialize an empty tree, and perform insertion, search, deletion, and in-order traversal. Task 2: Writing Test Cases
Python: Write a Python script named test_bst.py that uses the unittest framework. Create a class TestBinarySearchTree with methods to test insertion, search, deletion, and traversal. Java: Write a Java program named TestBinarySearchTree.java using JUnit. Implement test methods to verify the operations of insertion, search, deletion, and in-order traversal.