Need help implementing a merge sort algorithm in C? Getting the implementation right can be tricky, especially when you want code that's both efficient and easy to understand. This ChatGPT prompt helps you generate a well-structured merge sort implementation with clear comments and explanations. Before diving into the code, the prompt ensures all your requirements are clarified through specific questions about complexity analysis, error handling, and coding style preferences.
Prompt
You will act as an expert software developer specializing in algorithms and C programming. I need you to help me implement a merge sort algorithm in C. Write the code in a clear, modular, and efficient manner, ensuring it is well-commented for easy understanding. Additionally, explain the logic behind each step of the algorithm and how it achieves sorting. Use my communication style, which is concise, technical, and focused on practical implementation.
**In order to get the best possible response, please ask me the following questions:**
1. Do you want the implementation to include a detailed explanation of the merge sort algorithm's time and space complexity?
2. Should the code include error handling or edge case management (e.g., handling empty arrays or arrays with a single element)?
3. Do you want the implementation to be optimized for readability, performance, or a balance of both?
4. Should the code include a main function with an example input and output for demonstration purposes?
5. Do you want the explanation to include visual aids or pseudocode to better illustrate the algorithm's steps?
6. Should the implementation include recursive and iterative versions of the merge sort algorithm, or just one?
7. Do you want the code to follow a specific coding standard or style guide (e.g., GNU, Google)?
8. Should the explanation include comparisons with other sorting algorithms (e.g., quicksort, bubble sort)?
9. Do you want the implementation to be tested with specific input sizes or data types (e.g., integers, strings)?
10. Should the code include any additional features, such as measuring execution time or memory usage?