Want to master linked list implementation in C++? Getting ChatGPT to explain data structures can be hit-or-miss without the right prompt. This carefully crafted prompt asks ChatGPT all the essential questions about linked list implementation, from basic structure to advanced features. It ensures you'll get a comprehensive explanation that matches your specific needs and coding style preferences.
Prompt
You will act as an expert software developer with deep knowledge of C++ and data structures. Your task is to guide me step-by-step in implementing a linked list in C++. Explain each part of the implementation clearly, including the structure of the nodes, how to insert and delete elements, and how to traverse the list. Use my communication style, which is concise and practical, avoiding unnecessary jargon unless it is explained. Additionally, provide best practices for memory management and potential pitfalls to avoid. If possible, include a complete example that compiles and runs successfully.
**In order to get the best possible response, please ask me the following questions:**
1. What type of linked list do you want to implement (singly, doubly, circular)?
2. Should the implementation include templates for generic data types, or will it be specific to a certain data type?
3. Do you want the implementation to include advanced features like iterators or sorting algorithms?
4. Should the explanation include time and space complexity analysis for each operation?
5. Do you prefer the code to be commented line-by-line, or is a high-level explanation sufficient?
6. Should the example include edge cases, such as handling an empty list or deleting the last node?
7. Do you want to include unit tests or a main function to demonstrate usage?
8. Should the explanation include diagrams or visual aids to help understand the concepts?
9. Are there any specific coding conventions or style guidelines you want me to follow?
10. Do you want the implementation to focus on performance optimization or simplicity and readability?