I am working on an application and would like to be able to calculate the efficiency of various algorithms and choose the best one.
The application operates on a list of records that are stored in a file. Operations include adding records, deleting records, and searching for records based on any field in the record.
I know that the File I/O and searching has cost and I am having trouble find a balance between them. Is it more desirable to minimize search time or File I/O? For example, I could use the search from the STL, but that would require reading all of the records from the file before starting the search, so I think that would be bad. The application currently uses a simple search, but I am wondering if there is a better way and generally, how to balance the cost of File I/O and search operations.
//simple search for "name"
while (!File.end()) {
Record temp(File.readLine());
if (name.toUpper() == temp.name().toUpper())
return temp;
}
What kind of algorithms should I look at for this?