A Program
Write a program which allows the user to search for their favorite palindrome among a list. The user should be able to add and delete palindromes from the list. The program should keep results in the file palindrome.txt. The program must deal with a maximum of 1000 palindromes. You may assume palindrome.txt is in order.
- The basic data structure should be?
- What basic operations do we need?
- Read Palindromes from a file.
- Save Palindromes to a file.
- Search the array of palindromes
- Add/remove a palindrome.
- Add a palindrome to the list if there is space.
- Classify a palindrome at a given location.
- Do we need to
- Sort the palindromes?
- Classify the palindromes?
- I would start by writing the file input/output routines.
- File input
- Needs the array of strings and the number of elements as pass by reference
- The max size will be a global constant.
- The file name will be a global constant.
- Careful, no end of file bug here.
- File Output
- Needs the array of string, probably not reference but we have no choice.
- Needs the number of elements as a value.
- The file name will be a global constant.
- does not need max size
- I don't see any major problems.
- Search
- This will be used at the top level by users.
- And also as infrastructure to search for items to delete.
- Needs to be generic.
- Probably want a constant NOT_FOUND, what should the value be?
- What search algorithm?
- Add
- No major problems here,
- We probably want to search for it so we do not duplicate entries.
- Also check to make sure we don't overflow the array.
- Insert is going to take some thought.
- Delete
- Find the phrase to delete.
- This is going to take some thought.
- Insert
- Put the new palindrome at the end of the list
- Move it forward to the correct position.
- This is a modification of insertion sort.
- None of the above three do I/O, they are all basic operations.
- Classify
- Use the functions from the previous homework to classify a given palindrome.
- I would write a number of interface functions that perform user interaction and call the lower level functions.