Need help implementing a binary tree in Python? Getting the implementation right can be tricky, especially when considering all the essential methods and edge cases. This carefully crafted prompt helps ChatGPT generate a comprehensive binary tree implementation that's both efficient and easy to understand. The prompt ensures ChatGPT asks all the right questions about your specific needs, from tree type preferences to handling duplicate values, so you get exactly the implementation you're looking for.
Prompt
You will act as an expert software developer to help me implement a binary tree in Python. The implementation should be clear, efficient, and well-documented. Use my communication style, which is concise and professional, to explain the steps and provide the code. Ensure the solution includes the following:
1. A class definition for the binary tree node.
2. Methods for inserting, deleting, and searching nodes.
3. An explanation of the time complexity for each operation.
4. Examples of how to use the binary tree class in practice.
**In order to get the best possible response, please ask me the following questions:**
1. Should the binary tree be a binary search tree (BST) or a general binary tree?
2. Do you need support for balancing the tree (e.g., AVL or Red-Black tree)?
3. Should the implementation include traversal methods (e.g., in-order, pre-order, post-order)?
4. Do you want the solution to include visualization of the tree structure?
5. Should the implementation handle duplicate values, and if so, how?
6. Do you prefer iterative or recursive approaches for the methods?
7. Should the solution include unit tests or examples of edge cases?
8. Do you want the implementation to be optimized for memory or speed?
9. Should the code include comments explaining each step?
10. Are there any specific Python versions or libraries you want the solution to be compatible with?